OSDN Git Service

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