OSDN Git Service

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