OSDN Git Service

dd42c25c9ffab044a35a1338ceb3c9e8dc2b37f7
[hengband/hengband.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  * The table of "symbol info" -- each entry is a string of the form
1819  * "X:desc" where "X" is the trigger, and "desc" is the "info".
1820  */
1821 static cptr ident_info[] =
1822 {
1823 #ifdef JP
1824         " :°Å°Ç",
1825         "!:Ìô, ¥ª¥¤¥ë",
1826         "\":¥¢¥ß¥å¥ì¥Ã¥È, ðô¾þ¤ê",
1827         "#:ÊÉ(±£¤·¥É¥¢)Ëô¤Ï¿¢Êª",
1828         "$:ºâÊõ(¶â¤«ÊõÀÐ)",
1829         "%:¹ÛÌ®(Íϴ䤫ÀбÑ)",
1830         "&:Ȣ",
1831         "':³«¤¤¤¿¥É¥¢",
1832         "(:Æð¤é¤«¤¤Ëɶñ",
1833         "):½â",
1834         "*:ºâÊõ¤ò´Þ¤ó¤À¹ÛÌ®¤Þ¤¿¤Ïµå·Á¤Î²øʪ",
1835         "+:ÊĤ¸¤¿¥É¥¢",
1836         ",:¿©¤Ùʪ, ¤ª¤Ð¤±¥­¥Î¥³",
1837         "-:ËâË¡ËÀ, ¥í¥Ã¥É",
1838         ".:¾²",
1839         "/:´È¾õÉð´ï(¥¢¥Ã¥¯¥¹/¥Ñ¥¤¥¯/Åù)",
1840         "0:Çîʪ´Û¤ÎÆþ¸ý",
1841         "1:»¨²ß²°¤ÎÆþ¸ý",
1842         "2:Ëɶñ²°¤ÎÆþ¸ý",
1843         "3:Éð´ïÀìÌ珤ÎÆþ¸ý",
1844         "4:»û±¡¤ÎÆþ¸ý",
1845         "5:Ï£¶â½Ñ¤ÎŹ¤ÎÆþ¸ý",
1846         "6:ËâË¡¤ÎŹ¤ÎÆþ¸ý",
1847         "7:¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤ÎÆþ¸ý",
1848         "8:²æ¤¬²È¤ÎÆþ¸ý",
1849         "9:½ñŹ¤ÎÆþ¸ý",
1850         "::´äÀÐ",
1851         ";:²óÈò¤Î³¨Ê¸»ú/Çúȯ¤Î¥ë¡¼¥ó",
1852         "<:¾å¤ê³¬ÃÊ",
1853         "=:»ØÎØ",
1854         ">:²¼¤ê³¬ÃÊ",
1855         "?:´¬Êª",
1856         "@:¥×¥ì¥¤¥ä¡¼",
1857         "A:Å·»È",
1858         "B:Ļ",
1859         "C:¸¤",
1860         "D:¸ÅÂå¥É¥é¥´¥ó/¥ï¥¤¥¢¡¼¥à",
1861         "E:¥¨¥ì¥á¥ó¥¿¥ë",
1862         "F:¥È¥ó¥Ü",
1863         "G:¥´¡¼¥¹¥È",
1864         "H:»¨¼ï",
1865         "I:º«Ãî",
1866         "J:¥Ø¥Ó",
1867         "K:¥­¥é¡¼¡¦¥Ó¡¼¥È¥ë",
1868         "L:¥ê¥Ã¥Á",
1869         "M:¿¼ó¤Îà¨ÃîÎà",
1870         "N:Ææ¤ÎÀ¸Êª",
1871         "O:¥ª¡¼¥¬",
1872         "P:µðÂç¿Í´Ö·¿À¸Êª",
1873         "Q:¥¯¥¤¥ë¥¹¥ë¥°(Ì®ÂǤÄÆù²ô)",
1874         "R:à¨ÃîÎà/ξÀ¸Îà",
1875         "S:ÃØéá/¥µ¥½¥ê/¥À¥Ë",
1876         "T:¥È¥í¥ë",
1877         "U:¾åµé¥Ç¡¼¥â¥ó",
1878         "V:¥Ð¥ó¥Ñ¥¤¥¢",
1879         "W:¥ï¥¤¥È/¥ì¥¤¥¹/Åù",
1880         "X:¥¾¡¼¥ó/¥¶¥ì¥ó/Åù",
1881         "Y:¥¤¥¨¥Æ¥£",
1882         "Z:¥Ï¥¦¥ó¥É",
1883         "[:·ø¤¤¥¢¡¼¥Þ¡¼",
1884         "\\:Æß´ï(¥á¥¤¥¹/¥à¥Á/Åù)",
1885         "]:¼ï¡¹¤ÎËɶñ",
1886         "^:¥È¥é¥Ã¥×",
1887         "_:¾ó",
1888         "`:¿Í·Á¡¤Ä¦Áü",
1889         "a:¥¢¥ê",
1890         "b:¥³¥¦¥â¥ê",
1891         "c:¥à¥«¥Ç",
1892         "d:¥É¥é¥´¥ó",
1893         "e:ÌܶÌ",
1894         "f:¥Í¥³",
1895         "g:¥´¡¼¥ì¥à",
1896         "h:¥Û¥Ó¥Ã¥È/¥¨¥ë¥Õ/¥É¥ï¡¼¥Õ",
1897         "i:¥Ù¥È¥Ù¥È",
1898         "j:¥¼¥ê¡¼",
1899         "k:¥³¥Ü¥ë¥É",
1900         "l:¿åÀ³À¸Êª",
1901         "m:¥â¥ë¥É",
1902         "n:¥Ê¡¼¥¬",
1903         "o:¥ª¡¼¥¯",
1904         "p:¿Í´Ö",
1905         "q:»Í­½Ã",
1906         "r:¥Í¥º¥ß",
1907         "s:¥¹¥±¥ë¥È¥ó",
1908         "t:Ä®¤Î¿Í",
1909         "u:²¼µé¥Ç¡¼¥â¥ó",
1910         "v:¥Ü¥ë¥Æ¥Ã¥¯¥¹",
1911         "w:¥¤¥â¥à¥·/Âç·²",
1912         /* "x:unused", */
1913         "y:¥¤¡¼¥¯",
1914         "z:¥¾¥ó¥Ó/¥ß¥¤¥é",
1915         "{:Èô¤ÓÆ»¶ñ¤ÎÃÆ(Ìð/ÃÆ)",
1916         "|:Åá·õÎà(¥½¡¼¥É/¥À¥¬¡¼/Åù)",
1917         "}:Èô¤ÓÆ»¶ñ(µÝ/¥¯¥í¥¹¥Ü¥¦/¥¹¥ê¥ó¥°)",
1918         "~:¿å/ÍÏ´äή(¼ï¡¹¤Î¥¢¥¤¥Æ¥à)",
1919 #else
1920         " :A dark grid",
1921         "!:A potion (or oil)",
1922         "\":An amulet (or necklace)",
1923         "#:A wall (or secret door)",
1924         "$:Treasure (gold or gems)",
1925         "%:A vein (magma or quartz)",
1926         "&:A chest",
1927         "':An open door",
1928         "(:Soft armor",
1929         "):A shield",
1930         "*:A vein with treasure or a ball monster",
1931         "+:A closed door",
1932         ",:Food (or mushroom patch)",
1933         "-:A wand (or rod)",
1934         ".:Floor",
1935         "/:A polearm (Axe/Pike/etc)",
1936         "0:Entrance to Museum",
1937         "1:Entrance to General Store",
1938         "2:Entrance to Armory",
1939         "3:Entrance to Weaponsmith",
1940         "4:Entrance to Temple",
1941         "5:Entrance to Alchemy shop",
1942         "6:Entrance to Magic store",
1943         "7:Entrance to Black Market",
1944         "8:Entrance to your home",
1945         "9:Entrance to the bookstore",
1946         "::Rubble",
1947         ";:A glyph of warding / explosive rune",
1948         "<:An up staircase",
1949         "=:A ring",
1950         ">:A down staircase",
1951         "?:A scroll",
1952         "@:You",
1953         "A:Angel",
1954         "B:Bird",
1955         "C:Canine",
1956         "D:Ancient Dragon/Wyrm",
1957         "E:Elemental",
1958         "F:Dragon Fly",
1959         "G:Ghost",
1960         "H:Hybrid",
1961         "I:Insect",
1962         "J:Snake",
1963         "K:Killer Beetle",
1964         "L:Lich",
1965         "M:Multi-Headed Reptile",
1966         "N:Mystery Living",
1967         "O:Ogre",
1968         "P:Giant Humanoid",
1969         "Q:Quylthulg (Pulsing Flesh Mound)",
1970         "R:Reptile/Amphibian",
1971         "S:Spider/Scorpion/Tick",
1972         "T:Troll",
1973         "U:Major Demon",
1974         "V:Vampire",
1975         "W:Wight/Wraith/etc",
1976         "X:Xorn/Xaren/etc",
1977         "Y:Yeti",
1978         "Z:Zephyr Hound",
1979         "[:Hard armor",
1980         "\\:A hafted weapon (mace/whip/etc)",
1981         "]:Misc. armor",
1982         "^:A trap",
1983         "_:A staff",
1984         "`:A figurine or statue",
1985         "a:Ant",
1986         "b:Bat",
1987         "c:Centipede",
1988         "d:Dragon",
1989         "e:Floating Eye",
1990         "f:Feline",
1991         "g:Golem",
1992         "h:Hobbit/Elf/Dwarf",
1993         "i:Icky Thing",
1994         "j:Jelly",
1995         "k:Kobold",
1996         "l:Aquatic monster",
1997         "m:Mold",
1998         "n:Naga",
1999         "o:Orc",
2000         "p:Person/Human",
2001         "q:Quadruped",
2002         "r:Rodent",
2003         "s:Skeleton",
2004         "t:Townsperson",
2005         "u:Minor Demon",
2006         "v:Vortex",
2007         "w:Worm/Worm-Mass",
2008         /* "x:unused", */
2009         "y:Yeek",
2010         "z:Zombie/Mummy",
2011         "{:A missile (arrow/bolt/shot)",
2012         "|:An edged weapon (sword/dagger/etc)",
2013         "}:A launcher (bow/crossbow/sling)",
2014         "~:Fluid terrain (or miscellaneous item)",
2015 #endif
2016
2017         NULL
2018 };
2019
2020
2021 /*
2022  * Sorting hook -- Comp function -- see below
2023  *
2024  * We use "u" to point to array of monster indexes,
2025  * and "v" to select the type of sorting to perform on "u".
2026  */
2027 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
2028 {
2029         u16b *who = (u16b*)(u);
2030
2031         u16b *why = (u16b*)(v);
2032
2033         int w1 = who[a];
2034         int w2 = who[b];
2035
2036         int z1, z2;
2037
2038
2039         /* Sort by player kills */
2040         if (*why >= 4)
2041         {
2042                 /* Extract player kills */
2043                 z1 = r_info[w1].r_pkills;
2044                 z2 = r_info[w2].r_pkills;
2045
2046                 /* Compare player kills */
2047                 if (z1 < z2) return (TRUE);
2048                 if (z1 > z2) return (FALSE);
2049         }
2050
2051
2052         /* Sort by total kills */
2053         if (*why >= 3)
2054         {
2055                 /* Extract total kills */
2056                 z1 = r_info[w1].r_tkills;
2057                 z2 = r_info[w2].r_tkills;
2058
2059                 /* Compare total kills */
2060                 if (z1 < z2) return (TRUE);
2061                 if (z1 > z2) return (FALSE);
2062         }
2063
2064
2065         /* Sort by monster level */
2066         if (*why >= 2)
2067         {
2068                 /* Extract levels */
2069                 z1 = r_info[w1].level;
2070                 z2 = r_info[w2].level;
2071
2072                 /* Compare levels */
2073                 if (z1 < z2) return (TRUE);
2074                 if (z1 > z2) return (FALSE);
2075         }
2076
2077
2078         /* Sort by monster experience */
2079         if (*why >= 1)
2080         {
2081                 /* Extract experience */
2082                 z1 = r_info[w1].mexp;
2083                 z2 = r_info[w2].mexp;
2084
2085                 /* Compare experience */
2086                 if (z1 < z2) return (TRUE);
2087                 if (z1 > z2) return (FALSE);
2088         }
2089
2090
2091         /* Compare indexes */
2092         return (w1 <= w2);
2093 }
2094
2095
2096 /*
2097  * Sorting hook -- Swap function -- see below
2098  *
2099  * We use "u" to point to array of monster indexes,
2100  * and "v" to select the type of sorting to perform.
2101  */
2102 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
2103 {
2104         u16b *who = (u16b*)(u);
2105
2106         u16b holder;
2107
2108         /* Swap */
2109         holder = who[a];
2110         who[a] = who[b];
2111         who[b] = holder;
2112 }
2113
2114
2115
2116 /*
2117  * Identify a character, allow recall of monsters
2118  *
2119  * Several "special" responses recall "multiple" monsters:
2120  *   ^A (all monsters)
2121  *   ^U (all unique monsters)
2122  *   ^N (all non-unique monsters)
2123  *
2124  * The responses may be sorted in several ways, see below.
2125  *
2126  * Note that the player ghosts are ignored. XXX XXX XXX
2127  */
2128 void do_cmd_query_symbol(void)
2129 {
2130         int             i, n, r_idx;
2131         char    sym, query;
2132         char    buf[128];
2133
2134         bool    all = FALSE;
2135         bool    uniq = FALSE;
2136         bool    norm = FALSE;
2137         char    temp[80] = "";
2138
2139         bool    recall = FALSE;
2140
2141         u16b    why = 0;
2142         u16b    *who;
2143
2144         /* Get a character, or abort */
2145 #ifdef JP
2146         if (!get_com("ÃΤꤿ¤¤Ê¸»ú¤òÆþÎϤ·¤Æ²¼¤µ¤¤(µ­¹æ or ^AÁ´,^U¥æ,^NÈó¥æ,^M̾Á°): ", &sym, FALSE)) return;
2147 #else
2148         if (!get_com("Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ", &sym, FALSE)) return;
2149 #endif
2150
2151
2152         /* Find that character info, and describe it */
2153         for (i = 0; ident_info[i]; ++i)
2154         {
2155                 if (sym == ident_info[i][0]) break;
2156         }
2157
2158         /* Describe */
2159         if (sym == KTRL('A'))
2160         {
2161                 all = TRUE;
2162 #ifdef JP
2163                 strcpy(buf, "Á´¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2164 #else
2165                 strcpy(buf, "Full monster list.");
2166 #endif
2167
2168         }
2169         else if (sym == KTRL('U'))
2170         {
2171                 all = uniq = TRUE;
2172 #ifdef JP
2173                 strcpy(buf, "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2174 #else
2175                 strcpy(buf, "Unique monster list.");
2176 #endif
2177
2178         }
2179         else if (sym == KTRL('N'))
2180         {
2181                 all = norm = TRUE;
2182 #ifdef JP
2183                 strcpy(buf, "¥æ¥Ë¡¼¥¯³°¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2184 #else
2185                 strcpy(buf, "Non-unique monster list.");
2186 #endif
2187
2188         }
2189         /* XTRA HACK WHATSEARCH */
2190         else if (sym == KTRL('M'))
2191         {
2192                 all = TRUE;
2193 #ifdef JP
2194                 if (!get_string("̾Á°(±Ñ¸ì¤Î¾ì¹ç¾®Ê¸»ú¤Ç²Ä)",temp, 70))
2195 #else
2196                 if (!get_string("Enter name:",temp, 70))
2197 #endif
2198                 {
2199                         temp[0]=0;
2200                         return;
2201                 }
2202 #ifdef JP
2203                 sprintf(buf, "̾Á°:%s¤Ë¥Þ¥Ã¥Á",temp);
2204 #else
2205                 sprintf(buf, "Monsters with a name \"%s\"",temp);
2206 #endif
2207         }
2208         else if (ident_info[i])
2209         {
2210                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
2211         }
2212         else
2213         {
2214 #ifdef JP
2215                 sprintf(buf, "%c - %s", sym, "̵¸ú¤Êʸ»ú");
2216 #else
2217                 sprintf(buf, "%c - %s.", sym, "Unknown Symbol");
2218 #endif
2219
2220         }
2221
2222         /* Display the result */
2223         prt(buf, 0, 0);
2224
2225         /* Allocate the "who" array */
2226         C_MAKE(who, max_r_idx, u16b);
2227
2228         /* Collect matching monsters */
2229         for (n = 0, i = 1; i < max_r_idx; i++)
2230         {
2231                 monster_race *r_ptr = &r_info[i];
2232
2233                 /* Nothing to recall */
2234                 if (!cheat_know && !r_ptr->r_sights) continue;
2235
2236                 /* Require non-unique monsters if needed */
2237                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
2238
2239                 /* Require unique monsters if needed */
2240                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
2241
2242                 /* XTRA HACK WHATSEARCH */
2243                 if (temp[0]){
2244                   int xx;
2245                   char temp2[80];
2246   
2247                   for (xx=0; temp[xx] && xx<80; xx++){
2248 #ifdef JP
2249                     if (iskanji( temp[xx])) { xx++; continue; }
2250 #endif
2251                     if (isupper(temp[xx])) temp[xx]=tolower(temp[xx]);
2252                   }
2253   
2254 #ifdef JP
2255                   strcpy(temp2, r_name+r_ptr->E_name);
2256 #else
2257                   strcpy(temp2, r_name+r_ptr->name);
2258 #endif
2259                   for (xx=0; temp2[xx] && xx<80; xx++)
2260                     if (isupper(temp2[xx])) temp2[xx]=tolower(temp2[xx]);
2261   
2262 #ifdef JP
2263                   if (strstr(temp2, temp) || strstr_j(r_name + r_ptr->name, temp) )
2264 #else
2265                   if (strstr(temp2, temp))
2266 #endif
2267                           who[n++]=i;
2268                 }else
2269                 /* Collect "appropriate" monsters */
2270                 if (all || (r_ptr->d_char == sym)) who[n++] = i;
2271         }
2272
2273         /* Nothing to recall */
2274         if (!n)
2275         {
2276                 /* Free the "who" array */
2277                 C_KILL(who, max_r_idx, u16b);
2278
2279                 return;
2280         }
2281
2282
2283         /* Prompt XXX XXX XXX */
2284 #ifdef JP
2285         put_str("»×¤¤½Ð¤ò¸«¤Þ¤¹¤«? (k:»¦³²½ç/y/n): ", 0, 36);
2286 #else
2287         put_str("Recall details? (k/y/n): ", 0, 40);
2288 #endif
2289
2290
2291         /* Query */
2292         query = inkey();
2293
2294         /* Restore */
2295         prt(buf, 0, 0);
2296
2297         why = 2;
2298
2299         /* Select the sort method */
2300         ang_sort_comp = ang_sort_comp_hook;
2301         ang_sort_swap = ang_sort_swap_hook;
2302
2303         /* Sort the array */
2304         ang_sort(who, &why, n);
2305
2306         /* Sort by kills (and level) */
2307         if (query == 'k')
2308         {
2309                 why = 4;
2310                 query = 'y';
2311         }
2312
2313         /* Catch "escape" */
2314         if (query != 'y')
2315         {
2316                 /* Free the "who" array */
2317                 C_KILL(who, max_r_idx, u16b);
2318
2319                 return;
2320         }
2321
2322         /* Sort if needed */
2323         if (why == 4)
2324         {
2325                 /* Select the sort method */
2326                 ang_sort_comp = ang_sort_comp_hook;
2327                 ang_sort_swap = ang_sort_swap_hook;
2328
2329                 /* Sort the array */
2330                 ang_sort(who, &why, n);
2331         }
2332
2333
2334         /* Start at the end */
2335         i = n - 1;
2336
2337         /* Scan the monster memory */
2338         while (1)
2339         {
2340                 /* Extract a race */
2341                 r_idx = who[i];
2342
2343                 /* Hack -- Auto-recall */
2344                 monster_race_track(r_idx);
2345
2346                 /* Hack -- Handle stuff */
2347                 handle_stuff();
2348
2349                 /* Hack -- Begin the prompt */
2350                 roff_top(r_idx);
2351
2352                 /* Hack -- Complete the prompt */
2353 #ifdef JP
2354                 Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ESC]");
2355 #else
2356                 Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]");
2357 #endif
2358
2359
2360                 /* Interact */
2361                 while (1)
2362                 {
2363                         /* Recall */
2364                         if (recall)
2365                         {
2366                                 /* Save the screen */
2367                                 screen_save();
2368
2369                                 /* Recall on screen */
2370                                 screen_roff(who[i], 0);
2371
2372                                 /* Hack -- Complete the prompt (again) */
2373 #ifdef JP
2374                                 Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ESC]");
2375 #else
2376                                 Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]");
2377 #endif
2378
2379                         }
2380
2381                         /* Command */
2382                         query = inkey();
2383
2384                         /* Unrecall */
2385                         if (recall)
2386                         {
2387                                 /* Restore */
2388                                 screen_load();
2389                         }
2390
2391                         /* Normal commands */
2392                         if (query != 'r') break;
2393
2394                         /* Toggle recall */
2395                         recall = !recall;
2396                 }
2397
2398                 /* Stop scanning */
2399                 if (query == ESCAPE) break;
2400
2401                 /* Move to "prev" monster */
2402                 if (query == '-')
2403                 {
2404                         if (++i == n)
2405                         {
2406                                 i = 0;
2407                                 if (!expand_list) break;
2408                         }
2409                 }
2410
2411                 /* Move to "next" monster */
2412                 else
2413                 {
2414                         if (i-- == 0)
2415                         {
2416                                 i = n - 1;
2417                                 if (!expand_list) break;
2418                         }
2419                 }
2420         }
2421
2422         /* Free the "who" array */
2423         C_KILL(who, max_r_idx, u16b);
2424
2425         /* Re-display the identity */
2426         prt(buf, 0, 0);
2427 }
2428
2429
2430 /*
2431  *  research_mon
2432  *  -KMW-
2433  */
2434 bool research_mon(void)
2435 {
2436         int i, n, r_idx;
2437         char sym, query;
2438         char buf[128];
2439
2440         bool notpicked;
2441
2442         bool recall = FALSE;
2443
2444         u16b why = 0;
2445
2446         u16b    *who;
2447
2448         /* XTRA HACK WHATSEARCH */
2449         bool    all = FALSE;
2450         bool    uniq = FALSE;
2451         bool    norm = FALSE;
2452         char temp[80] = "";
2453
2454         /* XTRA HACK REMEMBER_IDX */
2455         static int old_sym = '\0';
2456         static int old_i = 0;
2457
2458
2459         /* Save the screen */
2460         screen_save();
2461
2462         /* Get a character, or abort */
2463 #ifdef JP
2464 if (!get_com("¥â¥ó¥¹¥¿¡¼¤Îʸ»ú¤òÆþÎϤ·¤Æ²¼¤µ¤¤(µ­¹æ or ^AÁ´,^U¥æ,^NÈó¥æ,^M̾Á°):", &sym, FALSE)) 
2465 #else
2466         if (!get_com("Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ", &sym, FALSE))
2467 #endif
2468
2469         {
2470                 /* Restore */
2471                 screen_load();
2472
2473                 return (FALSE);
2474         }
2475
2476         /* Find that character info, and describe it */
2477         for (i = 0; ident_info[i]; ++i)
2478         {
2479                 if (sym == ident_info[i][0]) break;
2480         }
2481
2482                 /* XTRA HACK WHATSEARCH */
2483         if (sym == KTRL('A'))
2484         {
2485                 all = TRUE;
2486 #ifdef JP
2487                 strcpy(buf, "Á´¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2488 #else
2489                 strcpy(buf, "Full monster list.");
2490 #endif
2491         }
2492         else if (sym == KTRL('U'))
2493         {
2494                 all = uniq = TRUE;
2495 #ifdef JP
2496                 strcpy(buf, "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2497 #else
2498                 strcpy(buf, "Unique monster list.");
2499 #endif
2500         }
2501         else if (sym == KTRL('N'))
2502         {
2503                 all = norm = TRUE;
2504 #ifdef JP
2505                 strcpy(buf, "¥æ¥Ë¡¼¥¯³°¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2506 #else
2507                 strcpy(buf, "Non-unique monster list.");
2508 #endif
2509         }
2510         else if (sym == KTRL('M'))
2511         {
2512                 all = TRUE;
2513 #ifdef JP
2514                 if (!get_string("̾Á°(±Ñ¸ì¤Î¾ì¹ç¾®Ê¸»ú¤Ç²Ä)",temp, 70))
2515 #else
2516                 if (!get_string("Enter name:",temp, 70))
2517 #endif
2518                 {
2519                         temp[0]=0;
2520
2521                         /* Restore */
2522                         screen_load();
2523
2524                         return FALSE;
2525                 }
2526 #ifdef JP
2527                 sprintf(buf, "̾Á°:%s¤Ë¥Þ¥Ã¥Á",temp);
2528 #else
2529                 sprintf(buf, "Monsters with a name \"%s\"",temp);
2530 #endif
2531         }
2532         else if (ident_info[i])
2533         {
2534                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
2535         }
2536         else
2537         {
2538 #ifdef JP
2539 sprintf(buf, "%c - %s", sym, "̵¸ú¤Êʸ»ú");
2540 #else
2541                 sprintf(buf, "%c - %s.", sym, "Unknown Symbol");
2542 #endif
2543
2544         }
2545
2546         /* Display the result */
2547         prt(buf, 16, 10);
2548
2549
2550         /* Allocate the "who" array */
2551         C_MAKE(who, max_r_idx, u16b);
2552
2553         /* Collect matching monsters */
2554         for (n = 0, i = 1; i < max_r_idx; i++)
2555         {
2556                 monster_race *r_ptr = &r_info[i];
2557
2558                 /* XTRA HACK WHATSEARCH */
2559                 /* Require non-unique monsters if needed */
2560                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
2561
2562                 /* Require unique monsters if needed */
2563                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
2564
2565                 /* Ì¾Á°¸¡º÷ */
2566                 if (temp[0]){
2567                   int xx;
2568                   char temp2[80];
2569   
2570                   for (xx=0; temp[xx] && xx<80; xx++){
2571 #ifdef JP
2572                     if (iskanji( temp[xx])) { xx++; continue; }
2573 #endif
2574                     if (isupper(temp[xx])) temp[xx]=tolower(temp[xx]);
2575                   }
2576   
2577 #ifdef JP
2578                   strcpy(temp2, r_name+r_ptr->E_name);
2579 #else
2580                   strcpy(temp2, r_name+r_ptr->name);
2581 #endif
2582                   for (xx=0; temp2[xx] && xx<80; xx++)
2583                     if (isupper(temp2[xx])) temp2[xx]=tolower(temp2[xx]);
2584   
2585 #ifdef JP
2586                   if (strstr(temp2, temp) || strstr_j(r_name + r_ptr->name, temp) )
2587 #else
2588                   if (strstr(temp2, temp))
2589 #endif
2590                           who[n++]=i;
2591                 }
2592                 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
2593         }
2594
2595         /* Nothing to recall */
2596         if (!n)
2597         {
2598                 /* Free the "who" array */
2599                 C_KILL(who, max_r_idx, u16b);
2600
2601                 /* Restore */
2602                 screen_load();
2603
2604                 return (FALSE);
2605         }
2606
2607         /* Sort by level */
2608         why = 2;
2609         query = 'y';
2610
2611         /* Sort if needed */
2612         if (why)
2613         {
2614                 /* Select the sort method */
2615                 ang_sort_comp = ang_sort_comp_hook;
2616                 ang_sort_swap = ang_sort_swap_hook;
2617
2618                 /* Sort the array */
2619                 ang_sort(who, &why, n);
2620         }
2621
2622
2623         /* Start at the end */
2624         /* XTRA HACK REMEMBER_IDX */
2625         if (old_sym == sym && old_i < n) i = old_i;
2626         else i = n - 1;
2627
2628         notpicked = TRUE;
2629
2630         /* Scan the monster memory */
2631         while (notpicked)
2632         {
2633                 /* Extract a race */
2634                 r_idx = who[i];
2635
2636                 /* Save this monster ID */
2637                 p_ptr->monster_race_idx = r_idx;
2638
2639                 /* Hack -- Handle stuff */
2640                 handle_stuff();
2641
2642                 /* Hack -- Begin the prompt */
2643                 roff_top(r_idx);
2644
2645                 /* Hack -- Complete the prompt */
2646 #ifdef JP
2647 Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ' '¤Ç³¹Ô, ESC]");
2648 #else
2649                 Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC, space to continue]");
2650 #endif
2651
2652
2653                 /* Interact */
2654                 while (1)
2655                 {
2656                         /* Recall */
2657                         if (recall)
2658                         {
2659                                 /* Recall on screen */
2660                                 monster_race *r_ptr = &r_info[r_idx];
2661                                 int m;
2662
2663                                 /* Hack -- Maximal info */
2664                                 r_ptr->r_wake = r_ptr->r_ignore = MAX_UCHAR;
2665                                 
2666                                 /* Observe "maximal" attacks */
2667                                 for (m = 0; m < 4; m++)
2668                                 {
2669                                         /* Examine "actual" blows */
2670                                         if (r_ptr->blow[m].effect || r_ptr->blow[m].method)
2671                                         {
2672                                                 /* Hack -- maximal observations */
2673                                                 r_ptr->r_blows[m] = MAX_UCHAR;
2674                                         }
2675                                 }
2676                                 
2677                                 /* Hack -- maximal drops */
2678                                 r_ptr->r_drop_gold = r_ptr->r_drop_item =
2679                                         (((r_ptr->flags1 & RF1_DROP_4D2) ? 8 : 0) +
2680                                          ((r_ptr->flags1 & RF1_DROP_3D2) ? 6 : 0) +
2681                                          ((r_ptr->flags1 & RF1_DROP_2D2) ? 4 : 0) +
2682                                          ((r_ptr->flags1 & RF1_DROP_1D2) ? 2 : 0) +
2683                                          ((r_ptr->flags1 & RF1_DROP_90)  ? 1 : 0) +
2684                                          ((r_ptr->flags1 & RF1_DROP_60)  ? 1 : 0));
2685                                 
2686                                 /* Hack -- but only "valid" drops */
2687                                 if (r_ptr->flags1 & RF1_ONLY_GOLD) r_ptr->r_drop_item = 0;
2688                                 if (r_ptr->flags1 & RF1_ONLY_ITEM) r_ptr->r_drop_gold = 0;
2689                                 
2690                                 /* Hack -- observe many spells */
2691                                 r_ptr->r_cast_inate = MAX_UCHAR;
2692                                 r_ptr->r_cast_spell = MAX_UCHAR;
2693                                 
2694                                 /* Hack -- know all the flags */
2695                                 r_ptr->r_flags1 = r_ptr->flags1;
2696                                 r_ptr->r_flags2 = r_ptr->flags2;
2697                                 r_ptr->r_flags3 = r_ptr->flags3;
2698                                 r_ptr->r_flags4 = r_ptr->flags4;
2699                                 r_ptr->r_flags5 = r_ptr->flags5;
2700                                 r_ptr->r_flags6 = r_ptr->flags6;
2701                                 
2702                                 r_ptr->r_xtra1 |= MR1_SINKA;
2703                         
2704                                 /* know every thing mode */
2705                                 screen_roff(r_idx, 0x01);
2706                                 notpicked = FALSE;
2707
2708                                 /* XTRA HACK REMEMBER_IDX */
2709                                 old_sym = sym;
2710                                 old_i = i;
2711                         }
2712
2713                         /* Command */
2714                         query = inkey();
2715
2716                         /* Normal commands */
2717                         if (query != 'r') break;
2718
2719                         /* Toggle recall */
2720                         recall = !recall;
2721                 }
2722
2723                 /* Stop scanning */
2724                 if (query == ESCAPE) break;
2725
2726                 /* Move to "prev" monster */
2727                 if (query == '-')
2728                 {
2729                         if (++i == n)
2730                         {
2731                                 i = 0;
2732                                 if (!expand_list) break;
2733                         }
2734                 }
2735
2736                 /* Move to "next" monster */
2737                 else
2738                 {
2739                         if (i-- == 0)
2740                         {
2741                                 i = n - 1;
2742                                 if (!expand_list) break;
2743                         }
2744                 }
2745         }
2746
2747
2748         /* Re-display the identity */
2749         /* prt(buf, 5, 5);*/
2750
2751         /* Free the "who" array */
2752         C_KILL(who, max_r_idx, u16b);
2753
2754         /* Restore */
2755         screen_load();
2756
2757         return (!notpicked);
2758 }
2759