OSDN Git Service

ebb472ed206fee306835a5fddbed7985ecfa5a42
[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         /* Restrict the choices */
1286         item_tester_hook = item_tester_refill_torch;
1287
1288         q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
1289         s = _("他に松明がない。", "You have no extra torches.");
1290
1291         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1292
1293         o_ptr = ref_item(p_ptr, item);
1294         /* Get the item (in the pack) */
1295         if (item >= 0)
1296         {
1297                 o_ptr = &inventory[item];
1298         }
1299
1300         /* Get the item (on the floor) */
1301         else
1302         {
1303                 o_ptr = &o_list[0 - item];
1304         }
1305
1306
1307         /* Take a partial turn */
1308         p_ptr->energy_use = 50;
1309
1310         /* Access the primary torch */
1311         j_ptr = &inventory[INVEN_LITE];
1312
1313         /* Refuel */
1314         j_ptr->xtra4 += o_ptr->xtra4 + 5;
1315
1316         msg_print(_("松明を結合した。", "You combine the torches."));
1317
1318         /* Comment */
1319         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1320         {
1321                 j_ptr->xtra4 = 0;
1322                 msg_print(_("松明が消えてしまった!", "Your torch has gone out!"));
1323         }
1324         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1325         {
1326                 j_ptr->xtra4 = 0;
1327                 msg_print(_("しかし松明は全く光らない。", "Curiously, your torche don't light."));
1328         }
1329         /* Over-fuel message */
1330         else if (j_ptr->xtra4 >= FUEL_TORCH)
1331         {
1332                 j_ptr->xtra4 = FUEL_TORCH;
1333                 msg_print(_("松明の寿命は十分だ。", "Your torch is fully fueled."));
1334         }
1335
1336         /* Refuel message */
1337         else
1338         {
1339                 msg_print(_("松明はいっそう明るく輝いた。", "Your torch glows more brightly."));
1340         }
1341
1342         /* Decrease the item (from the pack) */
1343         if (item >= 0)
1344         {
1345                 inven_item_increase(item, -1);
1346                 inven_item_describe(item);
1347                 inven_item_optimize(item);
1348         }
1349
1350         /* Decrease the item (from the floor) */
1351         else
1352         {
1353                 floor_item_increase(0 - item, -1);
1354                 floor_item_describe(0 - item);
1355                 floor_item_optimize(0 - item);
1356         }
1357
1358         /* Recalculate torch */
1359         p_ptr->update |= (PU_TORCH);
1360 }
1361
1362
1363 /*!
1364  * @brief 燃料を補充するコマンドのメインルーチン
1365  * Refill the players lamp, or restock his torches
1366  * @return なし
1367  */
1368 void do_cmd_refill(void)
1369 {
1370         object_type *o_ptr;
1371
1372         /* Get the light */
1373         o_ptr = &inventory[INVEN_LITE];
1374
1375         if (p_ptr->special_defense & KATA_MUSOU)
1376         {
1377                 set_action(ACTION_NONE);
1378         }
1379
1380         /* It is nothing */
1381         if (o_ptr->tval != TV_LITE)
1382         {
1383                 msg_print(_("光源を装備していない。", "You are not wielding a light."));
1384         }
1385
1386         /* It's a lamp */
1387         else if (o_ptr->sval == SV_LITE_LANTERN)
1388         {
1389                 do_cmd_refill_lamp();
1390         }
1391
1392         /* It's a torch */
1393         else if (o_ptr->sval == SV_LITE_TORCH)
1394         {
1395                 do_cmd_refill_torch();
1396         }
1397
1398         /* No torch to refill */
1399         else
1400         {
1401                 msg_print(_("この光源は寿命を延ばせない。", "Your light cannot be refilled."));
1402         }
1403 }
1404
1405
1406 /*!
1407  * @brief ターゲットを設定するコマンドのメインルーチン
1408  * Target command
1409  * @return なし
1410  */
1411 void do_cmd_target(void)
1412 {
1413         /* Target set */
1414         if (target_set(TARGET_KILL))
1415         {
1416                 msg_print(_("ターゲット決定。", "Target Selected."));
1417         }
1418
1419         /* Target aborted */
1420         else
1421         {
1422                 msg_print(_("ターゲット解除。", "Target Aborted."));
1423         }
1424 }
1425
1426
1427
1428 /*!
1429  * @brief 周囲を見渡すコマンドのメインルーチン
1430  * Look command
1431  * @return なし
1432  */
1433 void do_cmd_look(void)
1434 {
1435         /*TEST*/
1436         p_ptr->window |= PW_MONSTER_LIST;
1437         window_stuff();
1438         /*TEST*/
1439
1440         /* Look around */
1441         if (target_set(TARGET_LOOK))
1442         {
1443                 msg_print(_("ターゲット決定。", "Target Selected."));
1444         }
1445 }
1446
1447
1448 /*!
1449  * @brief 位置を確認するコマンドのメインルーチン
1450  * Allow the player to examine other sectors on the map
1451  * @return なし
1452  */
1453 void do_cmd_locate(void)
1454 {
1455         int             dir, y1, x1, y2, x2;
1456
1457         char    tmp_val[80];
1458
1459         char    out_val[160];
1460
1461         int wid, hgt;
1462
1463         /* Get size */
1464         get_screen_size(&wid, &hgt);
1465
1466
1467         /* Start at current panel */
1468         y2 = y1 = panel_row_min;
1469         x2 = x1 = panel_col_min;
1470
1471         /* Show panels until done */
1472         while (1)
1473         {
1474                 /* Describe the location */
1475                 if ((y2 == y1) && (x2 == x1))
1476                 {
1477 #ifdef JP
1478                         strcpy(tmp_val, "真上");
1479 #else
1480                         tmp_val[0] = '\0';
1481 #endif
1482
1483                 }
1484                 else
1485                 {
1486 #ifdef JP
1487                         sprintf(tmp_val, "%s%s",
1488                                 ((y2 < y1) ? "北" : (y2 > y1) ? "南" : ""),
1489                                 ((x2 < x1) ? "西" : (x2 > x1) ? "東" : ""));
1490 #else
1491                         sprintf(tmp_val, "%s%s of",
1492                                 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1493                                 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1494 #endif
1495
1496                 }
1497
1498                 /* Prepare to ask which way to look */
1499                 sprintf(out_val, _("マップ位置 [%d(%02d),%d(%02d)] (プレイヤーの%s)  方向?", 
1500                                                "Map sector [%d(%02d),%d(%02d)], which is%s your sector.  Direction?"),
1501                         y2 / (hgt / 2), y2 % (hgt / 2),
1502                         x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1503
1504                 /* Assume no direction */
1505                 dir = 0;
1506
1507                 /* Get a direction */
1508                 while (!dir)
1509                 {
1510                         char command;
1511
1512                         /* Get a command (or Cancel) */
1513                         if (!get_com(out_val, &command, TRUE)) break;
1514
1515                         /* Extract the action (if any) */
1516                         dir = get_keymap_dir(command);
1517
1518                         /* Error */
1519                         if (!dir) bell();
1520                 }
1521
1522                 /* No direction */
1523                 if (!dir) break;
1524
1525                 /* Apply the motion */
1526                 if (change_panel(ddy[dir], ddx[dir]))
1527                 {
1528                         y2 = panel_row_min;
1529                         x2 = panel_col_min;
1530                 }
1531         }
1532
1533
1534         /* Recenter the map around the player */
1535         verify_panel();
1536
1537         p_ptr->update |= (PU_MONSTERS);
1538
1539         /* Redraw map */
1540         p_ptr->redraw |= (PR_MAP);
1541
1542         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1543
1544         /* Handle stuff */
1545         handle_stuff();
1546 }
1547
1548
1549
1550 /*!
1551  * @brief モンスター種族情報を特定の基準によりソートするための比較処理
1552  * Sorting hook -- Comp function -- see below
1553  * @param u モンスター種族情報の入れるポインタ
1554  * @param v 条件基準ID
1555  * @param a 比較するモンスター種族のID1
1556  * @param b 比較するモンスター種族のID2
1557  * @return 2の方が大きければTRUEを返す
1558  * We use "u" to point to array of monster indexes,
1559  * and "v" to select the type of sorting to perform on "u".
1560  */
1561 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1562 {
1563         u16b *who = (u16b*)(u);
1564
1565         u16b *why = (u16b*)(v);
1566
1567         int w1 = who[a];
1568         int w2 = who[b];
1569
1570         int z1, z2;
1571
1572         /* Sort by player kills */
1573         if (*why >= 4)
1574         {
1575                 /* Extract player kills */
1576                 z1 = r_info[w1].r_pkills;
1577                 z2 = r_info[w2].r_pkills;
1578
1579                 /* Compare player kills */
1580                 if (z1 < z2) return (TRUE);
1581                 if (z1 > z2) return (FALSE);
1582         }
1583
1584
1585         /* Sort by total kills */
1586         if (*why >= 3)
1587         {
1588                 /* Extract total kills */
1589                 z1 = r_info[w1].r_tkills;
1590                 z2 = r_info[w2].r_tkills;
1591
1592                 /* Compare total kills */
1593                 if (z1 < z2) return (TRUE);
1594                 if (z1 > z2) return (FALSE);
1595         }
1596
1597
1598         /* Sort by monster level */
1599         if (*why >= 2)
1600         {
1601                 /* Extract levels */
1602                 z1 = r_info[w1].level;
1603                 z2 = r_info[w2].level;
1604
1605                 /* Compare levels */
1606                 if (z1 < z2) return (TRUE);
1607                 if (z1 > z2) return (FALSE);
1608         }
1609
1610
1611         /* Sort by monster experience */
1612         if (*why >= 1)
1613         {
1614                 /* Extract experience */
1615                 z1 = r_info[w1].mexp;
1616                 z2 = r_info[w2].mexp;
1617
1618                 /* Compare experience */
1619                 if (z1 < z2) return (TRUE);
1620                 if (z1 > z2) return (FALSE);
1621         }
1622
1623
1624         /* Compare indexes */
1625         return (w1 <= w2);
1626 }
1627
1628
1629 /*!
1630  * @brief モンスター種族情報を特定の基準によりソートするためのスワップ処理
1631  * Sorting hook -- Swap function -- see below
1632  * @param u モンスター種族情報の入れるポインタ
1633  * @param v 未使用
1634  * @param a スワップするモンスター種族のID1
1635  * @param b スワップするモンスター種族のID2
1636  * @return なし
1637  * @details
1638  * We use "u" to point to array of monster indexes,
1639  * and "v" to select the type of sorting to perform.
1640  */
1641 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1642 {
1643         u16b *who = (u16b*)(u);
1644
1645         u16b holder;
1646
1647         /* Unused */
1648         (void)v;
1649
1650         /* Swap */
1651         holder = who[a];
1652         who[a] = who[b];
1653         who[b] = holder;
1654 }
1655
1656
1657
1658 /*!
1659  * @brief モンスターの思い出を見るコマンドのメインルーチン
1660  * Identify a character, allow recall of monsters
1661  * @return なし
1662  * @details
1663  * <pre>
1664  * Several "special" responses recall "multiple" monsters:
1665  *   ^A (all monsters)
1666  *   ^U (all unique monsters)
1667  *   ^N (all non-unique monsters)
1668  *
1669  * The responses may be sorted in several ways, see below.
1670  *
1671  * Note that the player ghosts are ignored. 
1672  * </pre>
1673  */
1674 void do_cmd_query_symbol(void)
1675 {
1676         IDX i;
1677         int n;
1678         MONRACE_IDX r_idx;
1679         char    sym, query;
1680         char    buf[128];
1681
1682         bool    all = FALSE;
1683         bool    uniq = FALSE;
1684         bool    norm = FALSE;
1685         bool    ride = FALSE;
1686         char    temp[80] = "";
1687
1688         bool    recall = FALSE;
1689
1690         u16b    why = 0;
1691         IDX     *who;
1692
1693         /* Get a character, or abort */
1694         if (!get_com(_("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^R乗馬,^M名前): ", 
1695                                    "Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): "), &sym, FALSE)) return;
1696
1697         /* Find that character info, and describe it */
1698         for (i = 0; ident_info[i]; ++i)
1699         {
1700                 if (sym == ident_info[i][0]) break;
1701         }
1702
1703         /* Describe */
1704         if (sym == KTRL('A'))
1705         {
1706                 all = TRUE;
1707                 strcpy(buf, _("全モンスターのリスト", "Full monster list."));
1708         }
1709         else if (sym == KTRL('U'))
1710         {
1711                 all = uniq = TRUE;
1712                 strcpy(buf, _("ユニーク・モンスターのリスト", "Unique monster list."));
1713         }
1714         else if (sym == KTRL('N'))
1715         {
1716                 all = norm = TRUE;
1717                 strcpy(buf, _("ユニーク外モンスターのリスト", "Non-unique monster list."));
1718         }
1719         else if (sym == KTRL('R'))
1720         {
1721                 all = ride = TRUE;
1722                 strcpy(buf, _("乗馬可能モンスターのリスト", "Ridable monster list."));
1723         }
1724         /* XTRA HACK WHATSEARCH */
1725         else if (sym == KTRL('M'))
1726         {
1727                 all = TRUE;
1728                 if (!get_string(_("名前(英語の場合小文字で可)", "Enter name:"),temp, 70))
1729                 {
1730                         temp[0]=0;
1731                         return;
1732                 }
1733                 sprintf(buf, _("名前:%sにマッチ", "Monsters with a name \"%s\""),temp);
1734         }
1735         else if (ident_info[i])
1736         {
1737                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1738         }
1739         else
1740         {
1741                 sprintf(buf, "%c - %s", sym, _("無効な文字", "Unknown Symbol"));
1742         }
1743
1744         /* Display the result */
1745         prt(buf, 0, 0);
1746
1747         /* Allocate the "who" array */
1748         C_MAKE(who, max_r_idx, IDX);
1749
1750         /* Collect matching monsters */
1751         for (n = 0, i = 1; i < max_r_idx; i++)
1752         {
1753                 monster_race *r_ptr = &r_info[i];
1754
1755                 /* Nothing to recall */
1756                 if (!cheat_know && !r_ptr->r_sights) continue;
1757
1758                 /* Require non-unique monsters if needed */
1759                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
1760
1761                 /* Require unique monsters if needed */
1762                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
1763
1764                 /* Require ridable monsters if needed */
1765                 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
1766
1767                 /* XTRA HACK WHATSEARCH */
1768                 if (temp[0])
1769                 {
1770                         TERM_LEN xx;
1771                         char temp2[80];
1772
1773                         for (xx = 0; temp[xx] && xx < 80; xx++)
1774                         {
1775 #ifdef JP
1776                                 if (iskanji(temp[xx])) { xx++; continue; }
1777 #endif
1778                                 if (isupper(temp[xx])) temp[xx] = (char)tolower(temp[xx]);
1779                         }
1780
1781 #ifdef JP
1782                         strcpy(temp2, r_name + r_ptr->E_name);
1783 #else
1784                         strcpy(temp2, r_name + r_ptr->name);
1785 #endif
1786                         for (xx = 0; temp2[xx] && xx < 80; xx++)
1787                                 if (isupper(temp2[xx])) temp2[xx] = (char)tolower(temp2[xx]);
1788
1789 #ifdef JP
1790                         if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp))
1791 #else
1792                         if (my_strstr(temp2, temp))
1793 #endif
1794                                 who[n++] = i;
1795                 }
1796
1797                 /* Collect "appropriate" monsters */
1798                 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
1799         }
1800
1801         /* Nothing to recall */
1802         if (!n)
1803         {
1804                 /* Free the "who" array */
1805                 C_KILL(who, max_r_idx, IDX);
1806
1807                 return;
1808         }
1809
1810
1811         /* Prompt */
1812         put_str(_("思い出を見ますか? (k:殺害順/y/n): ", "Recall details? (k/y/n): "), 0, _(36, 40));
1813
1814
1815         /* Query */
1816         query = inkey();
1817
1818         /* Restore */
1819         prt(buf, 0, 0);
1820
1821         why = 2;
1822
1823         /* Select the sort method */
1824         ang_sort_comp = ang_sort_comp_hook;
1825         ang_sort_swap = ang_sort_swap_hook;
1826
1827         /* Sort the array */
1828         ang_sort(who, &why, n);
1829
1830         /* Sort by kills (and level) */
1831         if (query == 'k')
1832         {
1833                 why = 4;
1834                 query = 'y';
1835         }
1836
1837         /* Catch "escape" */
1838         if (query != 'y')
1839         {
1840                 /* Free the "who" array */
1841                 C_KILL(who, max_r_idx, IDX);
1842
1843                 return;
1844         }
1845
1846         /* Sort if needed */
1847         if (why == 4)
1848         {
1849                 /* Select the sort method */
1850                 ang_sort_comp = ang_sort_comp_hook;
1851                 ang_sort_swap = ang_sort_swap_hook;
1852
1853                 /* Sort the array */
1854                 ang_sort(who, &why, n);
1855         }
1856
1857
1858         /* Start at the end */
1859         i = n - 1;
1860
1861         /* Scan the monster memory */
1862         while (1)
1863         {
1864                 /* Extract a race */
1865                 r_idx = who[i];
1866
1867                 /* Hack -- Auto-recall */
1868                 monster_race_track(r_idx);
1869
1870                 /* Hack -- Handle stuff */
1871                 handle_stuff();
1872
1873                 /* Interact */
1874                 while (1)
1875                 {
1876                         /* Recall */
1877                         if (recall)
1878                         {
1879                                 /* Save the screen */
1880                                 screen_save();
1881
1882                                 /* Recall on screen */
1883                                 screen_roff(who[i], 0);
1884                         }
1885
1886                         /* Hack -- Begin the prompt */
1887                         roff_top(r_idx);
1888
1889                         /* Hack -- Complete the prompt */
1890                         Term_addstr(-1, TERM_WHITE, _(" ['r'思い出, ESC]", " [(r)ecall, ESC]"));
1891
1892                         /* Command */
1893                         query = inkey();
1894
1895                         /* Unrecall */
1896                         if (recall)
1897                         {
1898                                 /* Restore */
1899                                 screen_load();
1900                         }
1901
1902                         /* Normal commands */
1903                         if (query != 'r') break;
1904
1905                         /* Toggle recall */
1906                         recall = !recall;
1907                 }
1908
1909                 /* Stop scanning */
1910                 if (query == ESCAPE) break;
1911
1912                 /* Move to "prev" monster */
1913                 if (query == '-')
1914                 {
1915                         if (++i == n)
1916                         {
1917                                 i = 0;
1918                                 if (!expand_list) break;
1919                         }
1920                 }
1921
1922                 /* Move to "next" monster */
1923                 else
1924                 {
1925                         if (i-- == 0)
1926                         {
1927                                 i = n - 1;
1928                                 if (!expand_list) break;
1929                         }
1930                 }
1931         }
1932
1933         /* Free the "who" array */
1934         C_KILL(who, max_r_idx, IDX);
1935
1936         /* Re-display the identity */
1937         prt(buf, 0, 0);
1938 }
1939
1940 /*!
1941  * @brief アイテムを汎用的に「使う」コマンドのメインルーチン /
1942  * Use an item
1943  * @return なし
1944  * @details
1945  * XXX - Add actions for other item types
1946  */
1947 void do_cmd_use(void)
1948 {
1949         OBJECT_IDX item;
1950         object_type *o_ptr;
1951         cptr        q, s;
1952
1953         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1954         {
1955                 set_action(ACTION_NONE);
1956         }
1957
1958         item_tester_no_ryoute = TRUE;
1959         /* Prepare the hook */
1960         item_tester_hook = item_tester_hook_use;
1961
1962         q = _("どれを使いますか?", "Use which item? ");
1963         s = _("使えるものがありません。", "You have nothing to use.");
1964
1965         if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
1966
1967         /* Get the item (in the pack) */
1968         if (item >= 0)
1969         {
1970                 o_ptr = &inventory[item];
1971         }
1972         /* Get the item (on the floor) */
1973         else
1974         {
1975                 o_ptr = &o_list[0 - item];
1976         }
1977
1978         switch (o_ptr->tval)
1979         {
1980                 /* Spike a door */
1981                 case TV_SPIKE:
1982                 {
1983                         do_cmd_spike();
1984                         break;
1985                 }
1986
1987                 /* Eat some food */
1988                 case TV_FOOD:
1989                 {
1990                         do_cmd_eat_food_aux(item);
1991                         break;
1992                 }
1993
1994                 /* Aim a wand */
1995                 case TV_WAND:
1996                 {
1997                         do_cmd_aim_wand_aux(item);
1998                         break;
1999                 }
2000
2001                 /* Use a staff */
2002                 case TV_STAFF:
2003                 {
2004                         do_cmd_use_staff_aux(item);
2005                         break;
2006                 }
2007
2008                 /* Zap a rod */
2009                 case TV_ROD:
2010                 {
2011                         do_cmd_zap_rod_aux(item);
2012                         break;
2013                 }
2014
2015                 /* Quaff a potion */
2016                 case TV_POTION:
2017                 {
2018                         do_cmd_quaff_potion_aux(item);
2019                         break;
2020                 }
2021
2022                 /* Read a scroll */
2023                 case TV_SCROLL:
2024                 {
2025                         /* Check some conditions */
2026                         if (p_ptr->blind)
2027                         {
2028                                 msg_print(_("目が見えない。", "You can't see anything."));
2029                                 return;
2030                         }
2031                         if (no_lite())
2032                         {
2033                                 msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
2034                                 return;
2035                         }
2036                         if (p_ptr->confused)
2037                         {
2038                                 msg_print(_("混乱していて読めない!", "You are too confused!"));
2039                                 return;
2040                         }
2041
2042                   do_cmd_read_scroll_aux(item, TRUE);
2043                   break;
2044                 }
2045
2046                 /* Fire ammo */
2047                 case TV_SHOT:
2048                 case TV_ARROW:
2049                 case TV_BOLT:
2050                 {
2051                         do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
2052                         break;
2053                 }
2054
2055                 /* Activate an artifact */
2056                 default:
2057                 {
2058                         do_cmd_activate_aux(item);
2059                         break;
2060                 }
2061         }
2062 }
2063