OSDN Git Service

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