OSDN Git Service

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