OSDN Git Service

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