OSDN Git Service

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