OSDN Git Service

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