OSDN Git Service

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