OSDN Git Service

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