OSDN Git Service

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