OSDN Git Service

32bitで足りない場合の演算コードの一般的な関数群 s64b_???()を作った。
[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, (OD_OMIT_PREFIX | OD_NAME_ONLY));
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], (OD_OMIT_PREFIX | OD_NAME_ONLY));
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, (OD_OMIT_PREFIX | OD_NAME_ONLY));
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, (OD_OMIT_PREFIX | OD_NAME_ONLY));
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                 autopick_alter_item(item, FALSE);
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, 0);
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, 0);
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, 0);
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, 0);
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         /* Verify unless quantity given beforehand */
913         if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
914         {
915                 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
916
917                 /* Make a verification */
918                 sprintf(out_val, 
919 #ifdef JP
920                         "ËÜÅö¤Ë%s¤ò²õ¤·¤Þ¤¹¤«? [y/n/Auto]",
921 #else
922                         "Really destroy %s? [y/n/Auto]",
923 #endif
924                         o_name);
925
926                 msg_print(NULL);
927
928                 /* HACK : Add the line to message buffer */
929                 message_add(out_val);
930                 p_ptr->window |= (PW_MESSAGE);
931                 window_stuff();
932
933                 /* Get an acceptable answer */
934                 while (TRUE)
935                 {
936                         char i;
937
938                         /* Prompt */
939                         prt(out_val, 0, 0);
940
941                         i = inkey();
942
943                         /* Erase the prompt */
944                         prt("", 0, 0);
945
946
947                         if (i == 'y' || i == 'Y')
948                         {
949                                 break;
950                         }
951                         if (i == ESCAPE || i == 'n' || i == 'N')
952                         {
953                                 /* Cancel */
954                                 return;
955                         }
956                         if (i == 'A')
957                         {
958                                 /* Add an auto-destroy preference line */
959                                 if (autopick_autoregister(o_ptr))
960                                 {
961                                         /* Auto-destroy it */
962                                         autopick_alter_item(item, TRUE);
963                                 }
964
965                                 /* The object is already destroyed. */
966                                 return;
967                         }
968                 } /* while (TRUE) */
969         }
970
971         /* See how many items */
972         if (o_ptr->number > 1)
973         {
974                 /* Get a quantity */
975                 amt = get_quantity(NULL, o_ptr->number);
976
977                 /* Allow user abort */
978                 if (amt <= 0) return;
979         }
980
981
982         /* Describe the object */
983         old_number = o_ptr->number;
984         o_ptr->number = amt;
985         object_desc(o_name, o_ptr, 0);
986         o_ptr->number = old_number;
987
988         /* Take a turn */
989         energy_use = 100;
990
991         /* Artifacts cannot be destroyed */
992         if (!can_player_destroy_object(o_ptr))
993         {
994                 energy_use = 0;
995
996                 /* Message */
997 #ifdef JP
998                 msg_format("%s¤ÏÇ˲õÉÔ²Äǽ¤À¡£", o_name);
999 #else
1000                 msg_format("You cannot destroy %s.", o_name);
1001 #endif
1002
1003                 /* Done */
1004                 return;
1005         }
1006
1007         object_copy(q_ptr, o_ptr);
1008
1009         /* Message */
1010 #ifdef JP
1011         msg_format("%s¤ò²õ¤·¤¿¡£", o_name);
1012 #else
1013         msg_format("You destroy %s.", o_name);
1014 #endif
1015
1016         sound(SOUND_DESTITEM);
1017
1018         /* Reduce the charges of rods/wands */
1019         reduce_charges(o_ptr, amt);
1020
1021         /* Eliminate the item (from the pack) */
1022         if (item >= 0)
1023         {
1024                 inven_item_increase(item, -amt);
1025                 inven_item_describe(item);
1026                 inven_item_optimize(item);
1027         }
1028
1029         /* Eliminate the item (from the floor) */
1030         else
1031         {
1032                 floor_item_increase(0 - item, -amt);
1033                 floor_item_describe(0 - item);
1034                 floor_item_optimize(0 - item);
1035         }
1036
1037         if (high_level_book(q_ptr))
1038         {
1039                 bool gain_expr = FALSE;
1040
1041                 if (p_ptr->prace == RACE_ANDROID)
1042                 {
1043                 }
1044                 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
1045                 {
1046                         gain_expr = TRUE;
1047                 }
1048                 else if (p_ptr->pclass == CLASS_PALADIN)
1049                 {
1050                         if (is_good_realm(p_ptr->realm1))
1051                         {
1052                                 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
1053                         }
1054                         else
1055                         {
1056                                 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
1057                         }
1058                 }
1059
1060                 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
1061                 {
1062                         s32b tester_exp = p_ptr->max_exp / 20;
1063                         if (tester_exp > 10000) tester_exp = 10000;
1064                         if (q_ptr->sval < 3) tester_exp /= 4;
1065                         if (tester_exp<1) tester_exp = 1;
1066
1067 #ifdef JP
1068 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1069 #else
1070                         msg_print("You feel more experienced.");
1071 #endif
1072
1073                         gain_exp(tester_exp * amt);
1074                 }
1075                 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
1076                 {
1077                         chg_virtue(V_UNLIFE, 1);
1078                         chg_virtue(V_VITALITY, -1);
1079                 }
1080                 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
1081                 {
1082                         chg_virtue(V_UNLIFE, -1);
1083                         chg_virtue(V_VITALITY, 1);
1084                 }
1085         
1086                 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
1087                         chg_virtue(V_ENCHANT, -1);
1088         
1089                 if (object_value_real(q_ptr) > 30000)
1090                         chg_virtue(V_SACRIFICE, 2);
1091         
1092                 else if (object_value_real(q_ptr) > 10000)
1093                         chg_virtue(V_SACRIFICE, 1);
1094         }
1095
1096         if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
1097                 chg_virtue(V_HARMONY, 1);
1098
1099         if (item >= INVEN_RARM) calc_android_exp();
1100 }
1101
1102
1103 /*
1104  * Observe an item which has been *identify*-ed
1105  */
1106 void do_cmd_observe(void)
1107 {
1108         int                     item;
1109
1110         object_type             *o_ptr;
1111
1112         char            o_name[MAX_NLEN];
1113
1114         cptr q, s;
1115
1116         item_tester_no_ryoute = TRUE;
1117         /* Get an item */
1118 #ifdef JP
1119         q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤Þ¤¹¤«? ";
1120         s = "Ä´¤Ù¤é¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
1121 #else
1122         q = "Examine which item? ";
1123         s = "You have nothing to examine.";
1124 #endif
1125
1126         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1127
1128         /* Get the item (in the pack) */
1129         if (item >= 0)
1130         {
1131                 o_ptr = &inventory[item];
1132         }
1133
1134         /* Get the item (on the floor) */
1135         else
1136         {
1137                 o_ptr = &o_list[0 - item];
1138         }
1139
1140
1141         /* Require full knowledge */
1142         if (!(o_ptr->ident & IDENT_MENTAL))
1143         {
1144 #ifdef JP
1145                 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ä¤¤¤ÆÆäËÃΤäƤ¤¤ë¤³¤È¤Ï¤Ê¤¤¡£");
1146 #else
1147                 msg_print("You have no special knowledge about that item.");
1148 #endif
1149
1150                 return;
1151         }
1152
1153
1154         /* Description */
1155         object_desc(o_name, o_ptr, 0);
1156
1157         /* Describe */
1158 #ifdef JP
1159         msg_format("%s¤òÄ´¤Ù¤Æ¤¤¤ë...", o_name);
1160 #else
1161         msg_format("Examining %s...", o_name);
1162 #endif
1163
1164         /* Describe it fully */
1165 #ifdef JP
1166         if (!screen_object(o_ptr, TRUE)) msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
1167 #else
1168         if (!screen_object(o_ptr, TRUE)) msg_print("You see nothing special.");
1169 #endif
1170
1171 }
1172
1173
1174
1175 /*
1176  * Remove the inscription from an object
1177  * XXX Mention item (when done)?
1178  */
1179 void do_cmd_uninscribe(void)
1180 {
1181         int   item;
1182
1183         object_type *o_ptr;
1184
1185         cptr q, s;
1186
1187         item_tester_no_ryoute = TRUE;
1188         /* Get an item */
1189 #ifdef JP
1190         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ÎÌäò¾Ã¤·¤Þ¤¹¤«? ";
1191         s = "Ìäò¾Ã¤»¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
1192 #else
1193         q = "Un-inscribe which item? ";
1194         s = "You have nothing to un-inscribe.";
1195 #endif
1196
1197         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1198
1199         /* Get the item (in the pack) */
1200         if (item >= 0)
1201         {
1202                 o_ptr = &inventory[item];
1203         }
1204
1205         /* Get the item (on the floor) */
1206         else
1207         {
1208                 o_ptr = &o_list[0 - item];
1209         }
1210
1211         /* Nothing to remove */
1212         if (!o_ptr->inscription)
1213         {
1214 #ifdef JP
1215                 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¾Ã¤¹¤Ù¤­Ì䬤ʤ¤¡£");
1216 #else
1217                 msg_print("That item had no inscription to remove.");
1218 #endif
1219
1220                 return;
1221         }
1222
1223         /* Message */
1224 #ifdef JP
1225         msg_print("Ìäò¾Ã¤·¤¿¡£");
1226 #else
1227         msg_print("Inscription removed.");
1228 #endif
1229
1230
1231         /* Remove the incription */
1232         o_ptr->inscription = 0;
1233
1234         /* Combine the pack */
1235         p_ptr->notice |= (PN_COMBINE);
1236
1237         /* Window stuff */
1238         p_ptr->window |= (PW_INVEN | PW_EQUIP);
1239
1240         /* .¤ä$¤Î´Ø·¸¤Ç, ºÆ·×»»¤¬É¬ÍפʤϤº -- henkma */
1241         p_ptr->update |= (PU_BONUS);
1242
1243 }
1244
1245
1246 /*
1247  * Inscribe an object with a comment
1248  */
1249 void do_cmd_inscribe(void)
1250 {
1251         int                     item;
1252
1253         object_type             *o_ptr;
1254
1255         char            o_name[MAX_NLEN];
1256
1257         char            out_val[80];
1258
1259         cptr q, s;
1260
1261         item_tester_no_ryoute = TRUE;
1262         /* Get an item */
1263 #ifdef JP
1264         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËÌäò¹ï¤ß¤Þ¤¹¤«? ";
1265         s = "Ìäò¹ï¤á¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
1266 #else
1267         q = "Inscribe which item? ";
1268         s = "You have nothing to inscribe.";
1269 #endif
1270
1271         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1272
1273         /* Get the item (in the pack) */
1274         if (item >= 0)
1275         {
1276                 o_ptr = &inventory[item];
1277         }
1278
1279         /* Get the item (on the floor) */
1280         else
1281         {
1282                 o_ptr = &o_list[0 - item];
1283         }
1284
1285         /* Describe the activity */
1286         object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1287
1288         /* Message */
1289 #ifdef JP
1290         msg_format("%s¤ËÌäò¹ï¤à¡£", o_name);
1291 #else
1292         msg_format("Inscribing %s.", o_name);
1293 #endif
1294
1295         msg_print(NULL);
1296
1297         /* Start with nothing */
1298         strcpy(out_val, "");
1299
1300         /* Use old inscription */
1301         if (o_ptr->inscription)
1302         {
1303                 /* Start with the old inscription */
1304                 strcpy(out_val, quark_str(o_ptr->inscription));
1305         }
1306
1307         /* Get a new inscription (possibly empty) */
1308 #ifdef JP
1309         if (get_string("ÌÃ: ", out_val, 80))
1310 #else
1311         if (get_string("Inscription: ", out_val, 80))
1312 #endif
1313         {
1314                 /* Save the inscription */
1315                 o_ptr->inscription = quark_add(out_val);
1316
1317                 /* Combine the pack */
1318                 p_ptr->notice |= (PN_COMBINE);
1319
1320                 /* Window stuff */
1321                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1322
1323                 /* .¤ä$¤Î´Ø·¸¤Ç, ºÆ·×»»¤¬É¬ÍפʤϤº -- henkma */
1324                 p_ptr->update |= (PU_BONUS);
1325         }
1326 }
1327
1328
1329
1330 /*
1331  * An "item_tester_hook" for refilling lanterns
1332  */
1333 static bool item_tester_refill_lantern(object_type *o_ptr)
1334 {
1335         /* Flasks of oil are okay */
1336         if (o_ptr->tval == TV_FLASK) return (TRUE);
1337
1338         /* Laterns are okay */
1339         if ((o_ptr->tval == TV_LITE) &&
1340             (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1341
1342         /* Assume not okay */
1343         return (FALSE);
1344 }
1345
1346
1347 /*
1348  * Refill the players lamp (from the pack or floor)
1349  */
1350 static void do_cmd_refill_lamp(void)
1351 {
1352         int item;
1353
1354         object_type *o_ptr;
1355         object_type *j_ptr;
1356
1357         cptr q, s;
1358
1359
1360         /* Restrict the choices */
1361         item_tester_hook = item_tester_refill_lantern;
1362
1363         /* Get an item */
1364 #ifdef JP
1365         q = "¤É¤ÎÌý¤Ä¤Ü¤«¤éÃí¤®¤Þ¤¹¤«? ";
1366         s = "Ìý¤Ä¤Ü¤¬¤Ê¤¤¡£";
1367 #else
1368         q = "Refill with which flask? ";
1369         s = "You have no flasks of oil.";
1370 #endif
1371
1372         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1373
1374         /* Get the item (in the pack) */
1375         if (item >= 0)
1376         {
1377                 o_ptr = &inventory[item];
1378         }
1379
1380         /* Get the item (on the floor) */
1381         else
1382         {
1383                 o_ptr = &o_list[0 - item];
1384         }
1385
1386
1387         /* Take a partial turn */
1388         energy_use = 50;
1389
1390         /* Access the lantern */
1391         j_ptr = &inventory[INVEN_LITE];
1392
1393         /* Refuel */
1394         j_ptr->xtra4 += o_ptr->xtra4;
1395
1396         /* Message */
1397 #ifdef JP
1398         msg_print("¥é¥ó¥×¤ËÌý¤òÃí¤¤¤À¡£");
1399 #else
1400         msg_print("You fuel your lamp.");
1401 #endif
1402
1403         /* Comment */
1404         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1405         {
1406                 j_ptr->xtra4 = 0;
1407 #ifdef JP
1408                 msg_print("¥é¥ó¥×¤¬¾Ã¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª");
1409 #else
1410                 msg_print("Your lamp has gone out!");
1411 #endif
1412         }
1413         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1414         {
1415                 j_ptr->xtra4 = 0;
1416 #ifdef JP
1417                 msg_print("¤·¤«¤·¥é¥ó¥×¤ÏÁ´¤¯¸÷¤é¤Ê¤¤¡£");
1418 #else
1419                 msg_print("Curiously, your lamp doesn't light.");
1420 #endif
1421         }
1422         else if (j_ptr->xtra4 >= FUEL_LAMP)
1423         {
1424                 j_ptr->xtra4 = FUEL_LAMP;
1425 #ifdef JP
1426                 msg_print("¥é¥ó¥×¤ÎÌý¤Ï°ìÇÕ¤À¡£");
1427 #else
1428                 msg_print("Your lamp is full.");
1429 #endif
1430
1431         }
1432
1433         /* Decrease the item (from the pack) */
1434         if (item >= 0)
1435         {
1436                 inven_item_increase(item, -1);
1437                 inven_item_describe(item);
1438                 inven_item_optimize(item);
1439         }
1440
1441         /* Decrease the item (from the floor) */
1442         else
1443         {
1444                 floor_item_increase(0 - item, -1);
1445                 floor_item_describe(0 - item);
1446                 floor_item_optimize(0 - item);
1447         }
1448
1449         /* Recalculate torch */
1450         p_ptr->update |= (PU_TORCH);
1451 }
1452
1453
1454 /*
1455  * An "item_tester_hook" for refilling torches
1456  */
1457 static bool item_tester_refill_torch(object_type *o_ptr)
1458 {
1459         /* Torches are okay */
1460         if ((o_ptr->tval == TV_LITE) &&
1461             (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1462
1463         /* Assume not okay */
1464         return (FALSE);
1465 }
1466
1467
1468 /*
1469  * Refuel the players torch (from the pack or floor)
1470  */
1471 static void do_cmd_refill_torch(void)
1472 {
1473         int item;
1474
1475         object_type *o_ptr;
1476         object_type *j_ptr;
1477
1478         cptr q, s;
1479
1480
1481         /* Restrict the choices */
1482         item_tester_hook = item_tester_refill_torch;
1483
1484         /* Get an item */
1485 #ifdef JP
1486         q = "¤É¤Î¾¾ÌÀ¤ÇÌÀ¤«¤ê¤ò¶¯¤á¤Þ¤¹¤«? ";
1487         s = "¾¤Ë¾¾ÌÀ¤¬¤Ê¤¤¡£";
1488 #else
1489         q = "Refuel with which torch? ";
1490         s = "You have no extra torches.";
1491 #endif
1492
1493         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1494
1495         /* Get the item (in the pack) */
1496         if (item >= 0)
1497         {
1498                 o_ptr = &inventory[item];
1499         }
1500
1501         /* Get the item (on the floor) */
1502         else
1503         {
1504                 o_ptr = &o_list[0 - item];
1505         }
1506
1507
1508         /* Take a partial turn */
1509         energy_use = 50;
1510
1511         /* Access the primary torch */
1512         j_ptr = &inventory[INVEN_LITE];
1513
1514         /* Refuel */
1515         j_ptr->xtra4 += o_ptr->xtra4 + 5;
1516
1517         /* Message */
1518 #ifdef JP
1519         msg_print("¾¾ÌÀ¤ò·ë¹ç¤·¤¿¡£");
1520 #else
1521         msg_print("You combine the torches.");
1522 #endif
1523
1524
1525         /* Comment */
1526         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1527         {
1528                 j_ptr->xtra4 = 0;
1529 #ifdef JP
1530                 msg_print("¾¾ÌÀ¤¬¾Ã¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª");
1531 #else
1532                 msg_print("Your torch has gone out!");
1533 #endif
1534         }
1535         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1536         {
1537                 j_ptr->xtra4 = 0;
1538 #ifdef JP
1539                 msg_print("¤·¤«¤·¾¾ÌÀ¤ÏÁ´¤¯¸÷¤é¤Ê¤¤¡£");
1540 #else
1541                 msg_print("Curiously, your torche don't light.");
1542 #endif
1543         }
1544         /* Over-fuel message */
1545         else if (j_ptr->xtra4 >= FUEL_TORCH)
1546         {
1547                 j_ptr->xtra4 = FUEL_TORCH;
1548 #ifdef JP
1549                 msg_print("¾¾ÌÀ¤Î¼÷Ì¿¤Ï½½Ê¬¤À¡£");
1550 #else
1551                 msg_print("Your torch is fully fueled.");
1552 #endif
1553
1554         }
1555
1556         /* Refuel message */
1557         else
1558         {
1559 #ifdef JP
1560                 msg_print("¾¾ÌÀ¤Ï¤¤¤Ã¤½¤¦ÌÀ¤ë¤¯µ±¤¤¤¿¡£");
1561 #else
1562                 msg_print("Your torch glows more brightly.");
1563 #endif
1564
1565         }
1566
1567         /* Decrease the item (from the pack) */
1568         if (item >= 0)
1569         {
1570                 inven_item_increase(item, -1);
1571                 inven_item_describe(item);
1572                 inven_item_optimize(item);
1573         }
1574
1575         /* Decrease the item (from the floor) */
1576         else
1577         {
1578                 floor_item_increase(0 - item, -1);
1579                 floor_item_describe(0 - item);
1580                 floor_item_optimize(0 - item);
1581         }
1582
1583         /* Recalculate torch */
1584         p_ptr->update |= (PU_TORCH);
1585 }
1586
1587
1588 /*
1589  * Refill the players lamp, or restock his torches
1590  */
1591 void do_cmd_refill(void)
1592 {
1593         object_type *o_ptr;
1594
1595         /* Get the light */
1596         o_ptr = &inventory[INVEN_LITE];
1597
1598         if (p_ptr->special_defense & KATA_MUSOU)
1599         {
1600                 set_action(ACTION_NONE);
1601         }
1602
1603         /* It is nothing */
1604         if (o_ptr->tval != TV_LITE)
1605         {
1606 #ifdef JP
1607                 msg_print("¸÷¸»¤òÁõÈ÷¤·¤Æ¤¤¤Ê¤¤¡£");
1608 #else
1609                 msg_print("You are not wielding a light.");
1610 #endif
1611
1612         }
1613
1614         /* It's a lamp */
1615         else if (o_ptr->sval == SV_LITE_LANTERN)
1616         {
1617                 do_cmd_refill_lamp();
1618         }
1619
1620         /* It's a torch */
1621         else if (o_ptr->sval == SV_LITE_TORCH)
1622         {
1623                 do_cmd_refill_torch();
1624         }
1625
1626         /* No torch to refill */
1627         else
1628         {
1629 #ifdef JP
1630                 msg_print("¤³¤Î¸÷¸»¤Ï¼÷Ì¿¤ò±ä¤Ð¤»¤Ê¤¤¡£");
1631 #else
1632                 msg_print("Your light cannot be refilled.");
1633 #endif
1634
1635         }
1636 }
1637
1638
1639 /*
1640  * Target command
1641  */
1642 void do_cmd_target(void)
1643 {
1644         /* Target set */
1645         if (target_set(TARGET_KILL))
1646         {
1647 #ifdef JP
1648                 msg_print("¥¿¡¼¥²¥Ã¥È·èÄê¡£");
1649 #else
1650                 msg_print("Target Selected.");
1651 #endif
1652
1653         }
1654
1655         /* Target aborted */
1656         else
1657         {
1658 #ifdef JP
1659                 msg_print("¥¿¡¼¥²¥Ã¥È²ò½ü¡£");
1660 #else
1661                 msg_print("Target Aborted.");
1662 #endif
1663
1664         }
1665 }
1666
1667
1668
1669 /*
1670  * Look command
1671  */
1672 void do_cmd_look(void)
1673 {
1674         /* Look around */
1675         if (target_set(TARGET_LOOK))
1676         {
1677 #ifdef JP
1678                 msg_print("¥¿¡¼¥²¥Ã¥È·èÄê¡£");
1679 #else
1680                 msg_print("Target Selected.");
1681 #endif
1682
1683         }
1684 }
1685
1686
1687
1688 /*
1689  * Allow the player to examine other sectors on the map
1690  */
1691 void do_cmd_locate(void)
1692 {
1693         int             dir, y1, x1, y2, x2;
1694
1695         char    tmp_val[80];
1696
1697         char    out_val[160];
1698
1699         int wid, hgt;
1700
1701         /* Get size */
1702         get_screen_size(&wid, &hgt);
1703
1704
1705         /* Start at current panel */
1706         y2 = y1 = panel_row_min;
1707         x2 = x1 = panel_col_min;
1708
1709         /* Show panels until done */
1710         while (1)
1711         {
1712                 /* Describe the location */
1713                 if ((y2 == y1) && (x2 == x1))
1714                 {
1715 #ifdef JP
1716                         strcpy(tmp_val, "¿¿¾å");
1717 #else
1718                         tmp_val[0] = '\0';
1719 #endif
1720
1721                 }
1722                 else
1723                 {
1724 #ifdef JP
1725                         sprintf(tmp_val, "%s%s",
1726                                 ((y2 < y1) ? "ËÌ" : (y2 > y1) ? "Æî" : ""),
1727                                 ((x2 < x1) ? "À¾" : (x2 > x1) ? "Åì" : ""));
1728 #else
1729                         sprintf(tmp_val, "%s%s of",
1730                                 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1731                                 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1732 #endif
1733
1734                 }
1735
1736                 /* Prepare to ask which way to look */
1737                 sprintf(out_val,
1738 #ifdef JP
1739                         "¥Þ¥Ã¥×°ÌÃÖ [%d(%02d),%d(%02d)] (¥×¥ì¥¤¥ä¡¼¤Î%s)  Êý¸þ?",
1740 #else
1741                         "Map sector [%d(%02d),%d(%02d)], which is%s your sector.  Direction?",
1742 #endif
1743
1744                         y2 / (hgt / 2), y2 % (hgt / 2),
1745                         x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1746
1747                 /* Assume no direction */
1748                 dir = 0;
1749
1750                 /* Get a direction */
1751                 while (!dir)
1752                 {
1753                         char command;
1754
1755                         /* Get a command (or Cancel) */
1756                         if (!get_com(out_val, &command, TRUE)) break;
1757
1758                         /* Extract the action (if any) */
1759                         dir = get_keymap_dir(command);
1760
1761                         /* Error */
1762                         if (!dir) bell();
1763                 }
1764
1765                 /* No direction */
1766                 if (!dir) break;
1767
1768                 /* Apply the motion */
1769                 if (change_panel(ddy[dir], ddx[dir]))
1770                 {
1771                         y2 = panel_row_min;
1772                         x2 = panel_col_min;
1773                 }
1774         }
1775
1776
1777         /* Recenter the map around the player */
1778         verify_panel();
1779
1780         /* Update stuff */
1781         p_ptr->update |= (PU_MONSTERS);
1782
1783         /* Redraw map */
1784         p_ptr->redraw |= (PR_MAP);
1785
1786         /* Window stuff */
1787         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1788
1789         /* Handle stuff */
1790         handle_stuff();
1791 }
1792
1793
1794
1795 /*
1796  * Sorting hook -- Comp function -- see below
1797  *
1798  * We use "u" to point to array of monster indexes,
1799  * and "v" to select the type of sorting to perform on "u".
1800  */
1801 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1802 {
1803         u16b *who = (u16b*)(u);
1804
1805         u16b *why = (u16b*)(v);
1806
1807         int w1 = who[a];
1808         int w2 = who[b];
1809
1810         int z1, z2;
1811
1812         /* Sort by player kills */
1813         if (*why >= 4)
1814         {
1815                 /* Extract player kills */
1816                 z1 = r_info[w1].r_pkills;
1817                 z2 = r_info[w2].r_pkills;
1818
1819                 /* Compare player kills */
1820                 if (z1 < z2) return (TRUE);
1821                 if (z1 > z2) return (FALSE);
1822         }
1823
1824
1825         /* Sort by total kills */
1826         if (*why >= 3)
1827         {
1828                 /* Extract total kills */
1829                 z1 = r_info[w1].r_tkills;
1830                 z2 = r_info[w2].r_tkills;
1831
1832                 /* Compare total kills */
1833                 if (z1 < z2) return (TRUE);
1834                 if (z1 > z2) return (FALSE);
1835         }
1836
1837
1838         /* Sort by monster level */
1839         if (*why >= 2)
1840         {
1841                 /* Extract levels */
1842                 z1 = r_info[w1].level;
1843                 z2 = r_info[w2].level;
1844
1845                 /* Compare levels */
1846                 if (z1 < z2) return (TRUE);
1847                 if (z1 > z2) return (FALSE);
1848         }
1849
1850
1851         /* Sort by monster experience */
1852         if (*why >= 1)
1853         {
1854                 /* Extract experience */
1855                 z1 = r_info[w1].mexp;
1856                 z2 = r_info[w2].mexp;
1857
1858                 /* Compare experience */
1859                 if (z1 < z2) return (TRUE);
1860                 if (z1 > z2) return (FALSE);
1861         }
1862
1863
1864         /* Compare indexes */
1865         return (w1 <= w2);
1866 }
1867
1868
1869 /*
1870  * Sorting hook -- Swap function -- see below
1871  *
1872  * We use "u" to point to array of monster indexes,
1873  * and "v" to select the type of sorting to perform.
1874  */
1875 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1876 {
1877         u16b *who = (u16b*)(u);
1878
1879         u16b holder;
1880
1881         /* Unused */
1882         (void)v;
1883
1884         /* Swap */
1885         holder = who[a];
1886         who[a] = who[b];
1887         who[b] = holder;
1888 }
1889
1890
1891
1892 /*
1893  * Identify a character, allow recall of monsters
1894  *
1895  * Several "special" responses recall "multiple" monsters:
1896  *   ^A (all monsters)
1897  *   ^U (all unique monsters)
1898  *   ^N (all non-unique monsters)
1899  *
1900  * The responses may be sorted in several ways, see below.
1901  *
1902  * Note that the player ghosts are ignored. XXX XXX XXX
1903  */
1904 void do_cmd_query_symbol(void)
1905 {
1906         int             i, n, r_idx;
1907         char    sym, query;
1908         char    buf[128];
1909
1910         bool    all = FALSE;
1911         bool    uniq = FALSE;
1912         bool    norm = FALSE;
1913         bool    ride = FALSE;
1914         char    temp[80] = "";
1915
1916         bool    recall = FALSE;
1917
1918         u16b    why = 0;
1919         u16b    *who;
1920
1921         /* Get a character, or abort */
1922 #ifdef JP
1923         if (!get_com("ÃΤꤿ¤¤Ê¸»ú¤òÆþÎϤ·¤Æ²¼¤µ¤¤(µ­¹æ or ^AÁ´,^U¥æ,^NÈó¥æ,^R¾èÇÏ,^M̾Á°): ", &sym, FALSE)) return;
1924 #else
1925         if (!get_com("Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ", &sym, FALSE)) return;
1926 #endif
1927
1928         /* Find that character info, and describe it */
1929         for (i = 0; ident_info[i]; ++i)
1930         {
1931                 if (sym == ident_info[i][0]) break;
1932         }
1933
1934         /* Describe */
1935         if (sym == KTRL('A'))
1936         {
1937                 all = TRUE;
1938 #ifdef JP
1939                 strcpy(buf, "Á´¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
1940 #else
1941                 strcpy(buf, "Full monster list.");
1942 #endif
1943         }
1944         else if (sym == KTRL('U'))
1945         {
1946                 all = uniq = TRUE;
1947 #ifdef JP
1948                 strcpy(buf, "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
1949 #else
1950                 strcpy(buf, "Unique monster list.");
1951 #endif
1952         }
1953         else if (sym == KTRL('N'))
1954         {
1955                 all = norm = TRUE;
1956 #ifdef JP
1957                 strcpy(buf, "¥æ¥Ë¡¼¥¯³°¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
1958 #else
1959                 strcpy(buf, "Non-unique monster list.");
1960 #endif
1961         }
1962         else if (sym == KTRL('R'))
1963         {
1964                 all = ride = TRUE;
1965 #ifdef JP
1966                 strcpy(buf, "¾èÇϲÄǽ¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
1967 #else
1968                 strcpy(buf, "Ridable monster list.");
1969 #endif
1970         }
1971         /* XTRA HACK WHATSEARCH */
1972         else if (sym == KTRL('M'))
1973         {
1974                 all = TRUE;
1975 #ifdef JP
1976                 if (!get_string("̾Á°(±Ñ¸ì¤Î¾ì¹ç¾®Ê¸»ú¤Ç²Ä)",temp, 70))
1977 #else
1978                 if (!get_string("Enter name:",temp, 70))
1979 #endif
1980                 {
1981                         temp[0]=0;
1982                         return;
1983                 }
1984 #ifdef JP
1985                 sprintf(buf, "̾Á°:%s¤Ë¥Þ¥Ã¥Á",temp);
1986 #else
1987                 sprintf(buf, "Monsters with a name \"%s\"",temp);
1988 #endif
1989         }
1990         else if (ident_info[i])
1991         {
1992                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
1993         }
1994         else
1995         {
1996 #ifdef JP
1997                 sprintf(buf, "%c - %s", sym, "̵¸ú¤Êʸ»ú");
1998 #else
1999                 sprintf(buf, "%c - %s.", sym, "Unknown Symbol");
2000 #endif
2001         }
2002
2003         /* Display the result */
2004         prt(buf, 0, 0);
2005
2006         /* Allocate the "who" array */
2007         C_MAKE(who, max_r_idx, u16b);
2008
2009         /* Collect matching monsters */
2010         for (n = 0, i = 1; i < max_r_idx; i++)
2011         {
2012                 monster_race *r_ptr = &r_info[i];
2013
2014                 /* Nothing to recall */
2015                 if (!cheat_know && !r_ptr->r_sights) continue;
2016
2017                 /* Require non-unique monsters if needed */
2018                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
2019
2020                 /* Require unique monsters if needed */
2021                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
2022
2023                 /* Require ridable monsters if needed */
2024                 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
2025
2026                 /* XTRA HACK WHATSEARCH */
2027                 if (temp[0])
2028                 {
2029                   int xx;
2030                   char temp2[80];
2031   
2032                   for (xx=0; temp[xx] && xx<80; xx++)
2033                   {
2034 #ifdef JP
2035                     if (iskanji( temp[xx])) { xx++; continue; }
2036 #endif
2037                     if (isupper(temp[xx])) temp[xx]=tolower(temp[xx]);
2038                   }
2039   
2040 #ifdef JP
2041                   strcpy(temp2, r_name+r_ptr->E_name);
2042 #else
2043                   strcpy(temp2, r_name+r_ptr->name);
2044 #endif
2045                   for (xx=0; temp2[xx] && xx<80; xx++)
2046                     if (isupper(temp2[xx])) temp2[xx]=tolower(temp2[xx]);
2047   
2048 #ifdef JP
2049                   if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp) )
2050 #else
2051                   if (my_strstr(temp2, temp))
2052 #endif
2053                           who[n++]=i;
2054                 }
2055
2056                 /* Collect "appropriate" monsters */
2057                 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
2058         }
2059
2060         /* Nothing to recall */
2061         if (!n)
2062         {
2063                 /* Free the "who" array */
2064                 C_KILL(who, max_r_idx, u16b);
2065
2066                 return;
2067         }
2068
2069
2070         /* Prompt XXX XXX XXX */
2071 #ifdef JP
2072         put_str("»×¤¤½Ð¤ò¸«¤Þ¤¹¤«? (k:»¦³²½ç/y/n): ", 0, 36);
2073 #else
2074         put_str("Recall details? (k/y/n): ", 0, 40);
2075 #endif
2076
2077
2078         /* Query */
2079         query = inkey();
2080
2081         /* Restore */
2082         prt(buf, 0, 0);
2083
2084         why = 2;
2085
2086         /* Select the sort method */
2087         ang_sort_comp = ang_sort_comp_hook;
2088         ang_sort_swap = ang_sort_swap_hook;
2089
2090         /* Sort the array */
2091         ang_sort(who, &why, n);
2092
2093         /* Sort by kills (and level) */
2094         if (query == 'k')
2095         {
2096                 why = 4;
2097                 query = 'y';
2098         }
2099
2100         /* Catch "escape" */
2101         if (query != 'y')
2102         {
2103                 /* Free the "who" array */
2104                 C_KILL(who, max_r_idx, u16b);
2105
2106                 return;
2107         }
2108
2109         /* Sort if needed */
2110         if (why == 4)
2111         {
2112                 /* Select the sort method */
2113                 ang_sort_comp = ang_sort_comp_hook;
2114                 ang_sort_swap = ang_sort_swap_hook;
2115
2116                 /* Sort the array */
2117                 ang_sort(who, &why, n);
2118         }
2119
2120
2121         /* Start at the end */
2122         i = n - 1;
2123
2124         /* Scan the monster memory */
2125         while (1)
2126         {
2127                 /* Extract a race */
2128                 r_idx = who[i];
2129
2130                 /* Hack -- Auto-recall */
2131                 monster_race_track(r_idx);
2132
2133                 /* Hack -- Handle stuff */
2134                 handle_stuff();
2135
2136                 /* Interact */
2137                 while (1)
2138                 {
2139                         /* Recall */
2140                         if (recall)
2141                         {
2142                                 /* Save the screen */
2143                                 screen_save();
2144
2145                                 /* Recall on screen */
2146                                 screen_roff(who[i], 0);
2147                         }
2148
2149                         /* Hack -- Begin the prompt */
2150                         roff_top(r_idx);
2151
2152                         /* Hack -- Complete the prompt */
2153 #ifdef JP
2154                         Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ESC]");
2155 #else
2156                         Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]");
2157 #endif
2158
2159                         /* Command */
2160                         query = inkey();
2161
2162                         /* Unrecall */
2163                         if (recall)
2164                         {
2165                                 /* Restore */
2166                                 screen_load();
2167                         }
2168
2169                         /* Normal commands */
2170                         if (query != 'r') break;
2171
2172                         /* Toggle recall */
2173                         recall = !recall;
2174                 }
2175
2176                 /* Stop scanning */
2177                 if (query == ESCAPE) break;
2178
2179                 /* Move to "prev" monster */
2180                 if (query == '-')
2181                 {
2182                         if (++i == n)
2183                         {
2184                                 i = 0;
2185                                 if (!expand_list) break;
2186                         }
2187                 }
2188
2189                 /* Move to "next" monster */
2190                 else
2191                 {
2192                         if (i-- == 0)
2193                         {
2194                                 i = n - 1;
2195                                 if (!expand_list) break;
2196                         }
2197                 }
2198         }
2199
2200         /* Free the "who" array */
2201         C_KILL(who, max_r_idx, u16b);
2202
2203         /* Re-display the identity */
2204         prt(buf, 0, 0);
2205 }
2206
2207