OSDN Git Service

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