OSDN Git Service

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