OSDN Git Service

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