OSDN Git Service

93368aa9b005584f53879b6beef135e73baedb57
[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¤ò±¦¼ê¤Ë¹½¤¨¤Ê¤ª¤·¤¿¡£", ol_name);
323 #else
324                         msg_format("You wield %s at right hand.", ol_name);
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) && wear_confirm &&
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_MUSIC_BOOK))
912         {
913                 if (o_ptr->sval > 1)
914                         return TRUE;
915                 else
916                         return FALSE;
917         }
918
919         return FALSE;
920 }
921
922
923 /*
924  * Destroy an item
925  */
926 void do_cmd_destroy(void)
927 {
928         int                     item, amt = 1;
929         int                     old_number;
930
931         bool            force = FALSE;
932
933         object_type             *o_ptr;
934         object_type             forge;
935         object_type             *q_ptr = &forge;
936
937         char            o_name[MAX_NLEN];
938
939         char            out_val[MAX_NLEN+40];
940
941         cptr q, s;
942
943         if (p_ptr->special_defense & KATA_MUSOU)
944         {
945                 set_action(ACTION_NONE);
946         }
947
948         /* Hack -- force destruction */
949         if (command_arg > 0) force = TRUE;
950
951
952         /* Get an item */
953 #ifdef JP
954         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²õ¤·¤Þ¤¹¤«? ";
955         s = "²õ¤»¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
956 #else
957         q = "Destroy which item? ";
958         s = "You have nothing to destroy.";
959 #endif
960
961         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
962
963         /* Get the item (in the pack) */
964         if (item >= 0)
965         {
966                 o_ptr = &inventory[item];
967         }
968
969         /* Get the item (on the floor) */
970         else
971         {
972                 o_ptr = &o_list[0 - item];
973         }
974
975
976         /* See how many items */
977         if (o_ptr->number > 1)
978         {
979                 /* Get a quantity */
980                 amt = get_quantity(NULL, o_ptr->number);
981
982                 /* Allow user abort */
983                 if (amt <= 0) return;
984         }
985
986
987         /* Describe the object */
988         old_number = o_ptr->number;
989         o_ptr->number = amt;
990         object_desc(o_name, o_ptr, TRUE, 3);
991         o_ptr->number = old_number;
992
993         /* Verify unless quantity given */
994         if (!force)
995         {
996                 if (confirm_destroy || (object_value(o_ptr) > 0))
997                 {
998                         /* Make a verification */
999 #ifdef JP
1000                 sprintf(out_val, "ËÜÅö¤Ë%s¤ò²õ¤·¤Þ¤¹¤«? ", o_name);
1001 #else
1002                         sprintf(out_val, "Really destroy %s? ", o_name);
1003 #endif
1004
1005                         if (!get_check(out_val)) return;
1006                 }
1007         }
1008
1009         /* Take a turn */
1010         energy_use = 100;
1011
1012         /* Artifacts cannot be destroyed */
1013         if (artifact_p(o_ptr) || o_ptr->art_name)
1014         {
1015                 byte feel = FEEL_SPECIAL;
1016
1017                 energy_use = 0;
1018
1019                 /* Message */
1020 #ifdef JP
1021                 msg_format("%s¤ÏÇ˲õÉÔ²Äǽ¤À¡£", o_name);
1022 #else
1023                 msg_format("You cannot destroy %s.", o_name);
1024 #endif
1025
1026
1027                 /* Hack -- Handle icky artifacts */
1028                 if (cursed_p(o_ptr) || broken_p(o_ptr)) feel = FEEL_TERRIBLE;
1029
1030                 /* Hack -- inscribe the artifact */
1031                 o_ptr->feeling = feel;
1032
1033                 /* We have "felt" it (again) */
1034                 o_ptr->ident |= (IDENT_SENSE);
1035
1036                 /* Combine the pack */
1037                 p_ptr->notice |= (PN_COMBINE);
1038
1039                 p_ptr->redraw |= (PR_EQUIPPY);
1040
1041                 /* Window stuff */
1042                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1043
1044                 /* Done */
1045                 return;
1046         }
1047
1048         object_copy(q_ptr, o_ptr);
1049
1050         /* Message */
1051 #ifdef JP
1052         msg_format("%s¤ò²õ¤·¤¿¡£", o_name);
1053 #else
1054         msg_format("You destroy %s.", o_name);
1055 #endif
1056
1057         sound(SOUND_DESTITEM);
1058
1059         /* Reduce the charges of rods/wands */
1060         reduce_charges(o_ptr, amt);
1061
1062         /* Eliminate the item (from the pack) */
1063         if (item >= 0)
1064         {
1065                 inven_item_increase(item, -amt);
1066                 inven_item_describe(item);
1067                 inven_item_optimize(item);
1068         }
1069
1070         /* Eliminate the item (from the floor) */
1071         else
1072         {
1073                 floor_item_increase(0 - item, -amt);
1074                 floor_item_describe(0 - item);
1075                 floor_item_optimize(0 - item);
1076         }
1077
1078         if (high_level_book(q_ptr))
1079         {
1080                 bool gain_expr = FALSE;
1081
1082                 if (p_ptr->prace == RACE_ANDROID)
1083                 {
1084                 }
1085                 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
1086                 {
1087                         gain_expr = TRUE;
1088                 }
1089                 else if (p_ptr->pclass == CLASS_PALADIN)
1090                 {
1091                         if (p_ptr->realm1 == REALM_LIFE)
1092                         {
1093                                 if (q_ptr->tval != TV_LIFE_BOOK) gain_expr = TRUE;
1094                         }
1095                         else
1096                         {
1097                                 if (q_ptr->tval == TV_LIFE_BOOK) gain_expr = TRUE;
1098                         }
1099                 }
1100
1101                 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
1102                 {
1103                         s32b tester_exp = p_ptr->max_exp / 20;
1104                         if (tester_exp > 10000) tester_exp = 10000;
1105                         if (q_ptr->sval < 3) tester_exp /= 4;
1106                         if (tester_exp<1) tester_exp = 1;
1107
1108 #ifdef JP
1109 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1110 #else
1111                         msg_print("You feel more experienced.");
1112 #endif
1113
1114                         gain_exp(tester_exp * amt);
1115                 }
1116                 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
1117                 {
1118                         chg_virtue(V_UNLIFE, 1);
1119                         chg_virtue(V_VITALITY, -1);
1120                 }
1121                 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
1122                 {
1123                         chg_virtue(V_UNLIFE, -1);
1124                         chg_virtue(V_VITALITY, 1);
1125                 }
1126         
1127                 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
1128                         chg_virtue(V_ENCHANT, -1);
1129         
1130                 if (object_value_real(q_ptr) > 30000)
1131                         chg_virtue(V_SACRIFICE, 2);
1132         
1133                 else if (object_value_real(q_ptr) > 10000)
1134                         chg_virtue(V_SACRIFICE, 1);
1135         }
1136
1137         if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
1138                 chg_virtue(V_HARMONY, 1);
1139
1140         if (item >= INVEN_RARM) calc_android_exp();
1141 }
1142
1143
1144 /*
1145  * Observe an item which has been *identify*-ed
1146  */
1147 void do_cmd_observe(void)
1148 {
1149         int                     item;
1150
1151         object_type             *o_ptr;
1152
1153         char            o_name[MAX_NLEN];
1154
1155         cptr q, s;
1156
1157         item_tester_no_ryoute = TRUE;
1158         /* Get an item */
1159 #ifdef JP
1160         q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤Þ¤¹¤«? ";
1161         s = "Ä´¤Ù¤é¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
1162 #else
1163         q = "Examine which item? ";
1164         s = "You have nothing to examine.";
1165 #endif
1166
1167         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1168
1169         /* Get the item (in the pack) */
1170         if (item >= 0)
1171         {
1172                 o_ptr = &inventory[item];
1173         }
1174
1175         /* Get the item (on the floor) */
1176         else
1177         {
1178                 o_ptr = &o_list[0 - item];
1179         }
1180
1181
1182         /* Require full knowledge */
1183         if (!(o_ptr->ident & IDENT_MENTAL))
1184         {
1185 #ifdef JP
1186                 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ä¤¤¤ÆÆäËÃΤäƤ¤¤ë¤³¤È¤Ï¤Ê¤¤¡£");
1187 #else
1188                 msg_print("You have no special knowledge about that item.");
1189 #endif
1190
1191                 return;
1192         }
1193
1194
1195         /* Description */
1196         object_desc(o_name, o_ptr, TRUE, 3);
1197
1198         /* Describe */
1199 #ifdef JP
1200         msg_format("%s¤òÄ´¤Ù¤Æ¤¤¤ë...", o_name);
1201 #else
1202         msg_format("Examining %s...", o_name);
1203 #endif
1204
1205         /* Describe it fully */
1206 #ifdef JP
1207         if (!identify_fully_aux(o_ptr)) msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
1208 #else
1209         if (!identify_fully_aux(o_ptr)) msg_print("You see nothing special.");
1210 #endif
1211
1212 }
1213
1214
1215
1216 /*
1217  * Remove the inscription from an object
1218  * XXX Mention item (when done)?
1219  */
1220 void do_cmd_uninscribe(void)
1221 {
1222         int   item;
1223
1224         object_type *o_ptr;
1225
1226         cptr q, s;
1227
1228         item_tester_no_ryoute = TRUE;
1229         /* Get an item */
1230 #ifdef JP
1231         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ÎÌäò¾Ã¤·¤Þ¤¹¤«? ";
1232         s = "Ìäò¾Ã¤»¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
1233 #else
1234         q = "Un-inscribe which item? ";
1235         s = "You have nothing to un-inscribe.";
1236 #endif
1237
1238         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1239
1240         /* Get the item (in the pack) */
1241         if (item >= 0)
1242         {
1243                 o_ptr = &inventory[item];
1244         }
1245
1246         /* Get the item (on the floor) */
1247         else
1248         {
1249                 o_ptr = &o_list[0 - item];
1250         }
1251
1252         /* Nothing to remove */
1253         if (!o_ptr->inscription)
1254         {
1255 #ifdef JP
1256                 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¾Ã¤¹¤Ù¤­Ì䬤ʤ¤¡£");
1257 #else
1258                 msg_print("That item had no inscription to remove.");
1259 #endif
1260
1261                 return;
1262         }
1263
1264         /* Message */
1265 #ifdef JP
1266         msg_print("Ìäò¾Ã¤·¤¿¡£");
1267 #else
1268         msg_print("Inscription removed.");
1269 #endif
1270
1271
1272         /* Remove the incription */
1273         o_ptr->inscription = 0;
1274
1275         /* Combine the pack */
1276         p_ptr->notice |= (PN_COMBINE);
1277
1278         /* Window stuff */
1279         p_ptr->window |= (PW_INVEN | PW_EQUIP);
1280 }
1281
1282 /*
1283  * Auto flag inscribe
1284  */
1285
1286 typedef struct flag_insc_table
1287 {
1288 #ifdef JP
1289         char *japanese;
1290 #endif
1291         char *english;
1292         u32b flag;
1293         int num;
1294         u32b except_flag;
1295 } flag_insc_table;
1296
1297 #ifdef JP
1298 static flag_insc_table flag_insc_plus[] =
1299 {
1300         { "¹¶", "At", TR1_BLOWS, 1, 0 },
1301         { "®", "Sp", TR1_SPEED, 1, 0 },
1302         { "ÏÓ", "St", TR1_STR, 1, 0 },
1303         { "ÃÎ", "In", TR1_INT, 1, 0 },
1304         { "¸­", "Wi", TR1_WIS, 1, 0 },
1305         { "´ï", "Dx", TR1_DEX, 1, 0 },
1306         { "ÂÑ", "Cn", TR1_CON, 1, 0 },
1307         { "̥", "Ch", TR1_CHR, 1, 0 },
1308         { "±£", "Sl", TR1_STEALTH, 1, 0 },
1309         { "õ", "Sr", TR1_SEARCH, 1, 0 },
1310         { "ÀÖ", "If", TR1_INFRA, 1, 0 },
1311         { "·¡", "Dg", TR1_TUNNEL, 1, 0 },
1312         { NULL, 0, 0, 0 }
1313 };
1314
1315 static flag_insc_table flag_insc_immune[] =
1316 {
1317         { "»À", "Ac", TR2_IM_ACID, 2, 0 },
1318         { "ÅÅ", "El", TR2_IM_ELEC, 2, 0 },
1319         { "²Ð", "Fi", TR2_IM_FIRE, 2, 0 },
1320         { "Îä", "Co", TR2_IM_COLD, 2, 0 },
1321         { NULL, 0, 0, 0 }
1322 };
1323
1324 static flag_insc_table flag_insc_resistance[] =
1325 {
1326         { "»À", "Ac", TR2_RES_ACID, 2, TR2_IM_ACID },
1327         { "ÅÅ", "El", TR2_RES_ELEC, 2, TR2_IM_ELEC },
1328         { "²Ð", "Fi", TR2_RES_FIRE, 2, TR2_IM_FIRE },
1329         { "Îä", "Co", TR2_RES_COLD, 2, TR2_IM_COLD },
1330         { "ÆÇ", "Po", TR2_RES_POIS, 2, 0 },
1331         { "Á®", "Li", TR2_RES_LITE, 2, 0 },
1332         { "°Å", "Dk", TR2_RES_DARK, 2, 0 },
1333         { "ÇË", "Sh", TR2_RES_SHARDS, 2, 0 },
1334         { "ÌÕ", "Bl", TR2_RES_BLIND, 2, 0 },
1335         { "Íð", "Cf", TR2_RES_CONF, 2, 0 },
1336         { "¹ì", "So", TR2_RES_SOUND, 2, 0 },
1337         { "¹ö", "Nt", TR2_RES_NETHER, 2, 0 },
1338         { "°ø", "Nx", TR2_RES_NEXUS, 2, 0 },
1339         { "ÆÙ", "Ca", TR2_RES_CHAOS, 2, 0 },
1340         { "Îô", "Di", TR2_RES_DISEN, 2, 0 },
1341         { "¶²", "Fe", TR2_RES_FEAR, 2, 0 },
1342         { NULL, 0, 0, 0 }
1343 };
1344
1345 static flag_insc_table flag_insc_misc[] =
1346 {
1347         { "ËâÎÏ", "Ma", TR3_DEC_MANA, 3, 0 },
1348         { "Åê", "Th", TR2_THROW, 2, 0 },
1349         { "ȿ", "Rf", TR2_REFLECT, 2, 0 },
1350         { "Ëã", "Fa", TR2_FREE_ACT, 2, 0 },
1351         { "»ë", "Si", TR3_SEE_INVIS, 3, 0 },
1352         { "·Ð", "Hl", TR2_HOLD_LIFE, 2, 0 },
1353         { "´¶", "Esp", TR3_TELEPATHY, 3, 0 },
1354         { "ÃÙ", "Sd", TR3_SLOW_DIGEST, 3, 0 },
1355         { "³è", "Rg", TR3_REGEN, 3, 0 },
1356         { "Éâ", "Lv", TR3_FEATHER, 3, 0 },
1357         { "ÌÀ", "Lu", TR3_LITE, 3, 0 },
1358         { "·Ù", "Wr", TR3_WARNING, 3, 0 },
1359         { "ÇÜ", "Xm", TR3_XTRA_MIGHT, 3, 0 },
1360         { "¼Í", "Xs", TR3_XTRA_SHOTS, 3, 0 },
1361         { "ÅÜ", "Ag", TR3_AGGRAVATE, 3, 0 },
1362         { "½Ë", "Bs", TR3_BLESSED, 3, 0 },
1363 #if 0
1364         { "±Ê¼ö", "Pc", TR3_PERMA_CURSE, 3, 0 },
1365         { "¼ö", "Cu", TR3_HEAVY_CURSE, 3, TR3_PERMA_CURSE },
1366         { "´÷", "Ty", TR3_TY_CURSE, 3, 0 },
1367 #endif
1368         { NULL, 0, 0, 0 }
1369 };
1370
1371 static flag_insc_table flag_insc_aura[] =
1372 {
1373         { "±ê", "F", TR3_SH_FIRE, 3, 0 },
1374         { "ÅÅ", "E", TR3_SH_ELEC, 3, 0 },
1375         { "Îä", "C", TR3_SH_COLD, 3, 0 },
1376         { "Ëâ", "M", TR3_NO_MAGIC, 3, 0 },
1377         { "½Ö", "T", TR3_NO_TELE, 3, 0 },
1378         { NULL, 0, 0, 0 }
1379 };
1380
1381 static flag_insc_table flag_insc_brand[] =
1382 {
1383         { "»À", "A", TR1_BRAND_ACID, 1, 0 },
1384         { "ÅÅ", "E", TR1_BRAND_ELEC, 1, 0 },
1385         { "¾Æ", "F", TR1_BRAND_FIRE, 1, 0 },
1386         { "Åà", "Co", TR1_BRAND_COLD, 1, 0 },
1387         { "ÆÇ", "P", TR1_BRAND_POIS, 1, 0 },
1388         { "ÆÙ", "Ca", TR1_CHAOTIC, 1, 0 },
1389         { "µÛ", "V", TR1_VAMPIRIC, 1, 0 },
1390         { "¿Ì", "Q", TR1_IMPACT, 1, 0 },
1391         { "ÀÚ", "S", TR1_VORPAL, 1, 0 },
1392         { "Íý", "M", TR1_FORCE_WEAPON, 1, 0 },
1393         { NULL, NULL, 0, 0, 0 }
1394 };
1395
1396 static flag_insc_table flag_insc_slay[] =
1397 {
1398         { "¼Ù", "*", TR1_SLAY_EVIL, 1, 0 },
1399         { "¿Í", "H", TR3_SLAY_HUMAN, 3, 0 },
1400         { "ζ", "D", TR1_KILL_DRAGON, 1, 0 },
1401         { "ε", "d", TR1_SLAY_DRAGON, 1, TR1_KILL_DRAGON },
1402         { "¥ª", "o", TR1_SLAY_ORC, 1, 0 },
1403         { "¥È", "T", TR1_SLAY_TROLL, 1, 0 },
1404         { "µð", "P", TR1_SLAY_GIANT, 1, 0 },
1405         { "¥Ç", "U", TR1_SLAY_DEMON, 1, 0 },
1406         { "»à", "L", TR1_SLAY_UNDEAD, 1, 0 },
1407         { "ư", "Z", TR1_SLAY_ANIMAL, 1, 0 },
1408         { NULL, NULL, 0, 0, 0 }
1409 };
1410
1411 static flag_insc_table flag_insc_sust[] =
1412 {
1413         { "ÏÓ", "St", TR2_SUST_STR, 2, 0 },
1414         { "ÃÎ", "In", TR2_SUST_INT, 2, 0 },
1415         { "¸­", "Wi", TR2_SUST_WIS, 2, 0 },
1416         { "´ï", "Dx", TR2_SUST_DEX, 2, 0 },
1417         { "ÂÑ", "Cn", TR2_SUST_CON, 2, 0 },
1418         { "̥", "Ch", TR2_SUST_CHR, 2, 0 },
1419         { NULL, NULL, 0, 0, 0 }
1420 };
1421
1422 #else
1423 static flag_insc_table flag_insc_plus[] =
1424 {
1425         { "At", TR1_BLOWS, 1, 0 },
1426         { "Sp", TR1_SPEED, 1, 0 },
1427         { "St", TR1_STR, 1, 0 },
1428         { "In", TR1_INT, 1, 0 },
1429         { "Wi", TR1_WIS, 1, 0 },
1430         { "Dx", TR1_DEX, 1, 0 },
1431         { "Cn", TR1_CON, 1, 0 },
1432         { "Ch", TR1_CHR, 1, 0 },
1433         { "Sl", TR1_STEALTH, 1, 0 },
1434         { "Sr", TR1_SEARCH, 1, 0 },
1435         { "If", TR1_INFRA, 1, 0 },
1436         { "Dg", TR1_TUNNEL, 1, 0 },
1437         { NULL, 0, 0, 0 }
1438 };
1439
1440 static flag_insc_table flag_insc_immune[] =
1441 {
1442         { "Ac", TR2_IM_ACID, 2, 0 },
1443         { "El", TR2_IM_ELEC, 2, 0 },
1444         { "Fi", TR2_IM_FIRE, 2, 0 },
1445         { "Co", TR2_IM_COLD, 2, 0 },
1446         { NULL, 0, 0, 0 }
1447 };
1448
1449 static flag_insc_table flag_insc_resistance[] =
1450 {
1451         { "Ac", TR2_RES_ACID, 2, TR2_IM_ACID },
1452         { "El", TR2_RES_ELEC, 2, TR2_IM_ELEC },
1453         { "Fi", TR2_RES_FIRE, 2, TR2_IM_FIRE },
1454         { "Co", TR2_RES_COLD, 2, TR2_IM_COLD },
1455         { "Po", TR2_RES_POIS, 2, 0 },
1456         { "Li", TR2_RES_LITE, 2, 0 },
1457         { "Dk", TR2_RES_DARK, 2, 0 },
1458         { "Sh", TR2_RES_SHARDS, 2, 0 },
1459         { "Bl", TR2_RES_BLIND, 2, 0 },
1460         { "Cf", TR2_RES_CONF, 2, 0 },
1461         { "So", TR2_RES_SOUND, 2, 0 },
1462         { "Nt", TR2_RES_NETHER, 2, 0 },
1463         { "Nx", TR2_RES_NEXUS, 2, 0 },
1464         { "Ca", TR2_RES_CHAOS, 2, 0 },
1465         { "Di", TR2_RES_DISEN, 2, 0 },
1466         { "Fe", TR2_RES_FEAR, 2, 0 },
1467         { NULL, 0, 0, 0 }
1468 };
1469
1470 static flag_insc_table flag_insc_misc[] =
1471 {
1472         { "Ma", TR3_DEC_MANA, 3, 0 },
1473         { "Th", TR2_THROW, 2, 0 },
1474         { "Rf", TR2_REFLECT, 2, 0 },
1475         { "Fa", TR2_FREE_ACT, 2, 0 },
1476         { "Si", TR3_SEE_INVIS, 3, 0 },
1477         { "Hl", TR2_HOLD_LIFE, 2, 0 },
1478         { "Esp", TR3_TELEPATHY, 3, 0 },
1479         { "Sd", TR3_SLOW_DIGEST, 3, 0 },
1480         { "Rg", TR3_REGEN, 3, 0 },
1481         { "Lv", TR3_FEATHER, 3, 0 },
1482         { "Lu", TR3_LITE, 3, 0 },
1483         { "Wr", TR3_WARNING, 3, 0 },
1484         { "Xm", TR3_XTRA_MIGHT, 3, 0 },
1485         { "Xs", TR3_XTRA_SHOTS, 3, 0 },
1486         { "Ag", TR3_AGGRAVATE, 3, 0 },
1487         { "Bs", TR3_BLESSED, 3, 0 },
1488 #if 0
1489         { "Pc", TR3_PERMA_CURSE, 3, 0 },
1490         { "Cu", TR3_HEAVY_CURSE, 3, TR3_PERMA_CURSE },
1491         { "Ty", TR3_TY_CURSE, 3, 0 },
1492 #endif
1493 #if 0
1494         { "De", TR3_DRAIN_EXP, 3, 0 },
1495 #endif
1496         { NULL, 0, 0, 0 }
1497 };
1498
1499 static flag_insc_table flag_insc_aura[] =
1500 {
1501         { "F", TR3_SH_FIRE, 3, 0 },
1502         { "E", TR3_SH_ELEC, 3, 0 },
1503         { "C", TR3_SH_COLD, 3, 0 },
1504         { "M", TR3_NO_MAGIC, 3, 0 },
1505         { "T", TR3_NO_TELE, 3, 0 },
1506         { NULL, 0, 0, 0 }
1507 };
1508
1509 static flag_insc_table flag_insc_brand[] =
1510 {
1511         { "A", TR1_BRAND_ACID, 1, 0 },
1512         { "E", TR1_BRAND_ELEC, 1, 0 },
1513         { "F", TR1_BRAND_FIRE, 1, 0 },
1514         { "Co", TR1_BRAND_COLD, 1, 0 },
1515         { "P", TR1_BRAND_POIS, 1, 0 },
1516         { "Ca", TR1_CHAOTIC, 1, 0 },
1517         { "V", TR1_VAMPIRIC, 1, 0 },
1518         { "Q", TR1_IMPACT, 1, 0 },
1519         { "S", TR1_VORPAL, 1, 0 },
1520         { "M", TR1_FORCE_WEAPON, 1, 0 },
1521         { NULL, 0, 0, 0 }
1522 };
1523
1524 static flag_insc_table flag_insc_slay[] =
1525 {
1526         { "*", TR1_SLAY_EVIL, 1, 0 },
1527         { "H", TR3_SLAY_HUMAN, 3, 0 },
1528         { "D", TR1_KILL_DRAGON, 1, 0 },
1529         { "d", TR1_SLAY_DRAGON, 1, TR1_KILL_DRAGON },
1530         { "o", TR1_SLAY_ORC, 1, 0 },
1531         { "T", TR1_SLAY_TROLL, 1, 0 },
1532         { "P", TR1_SLAY_GIANT, 1, 0 },
1533         { "U", TR1_SLAY_DEMON, 1, 0 },
1534         { "L", TR1_SLAY_UNDEAD, 1, 0 },
1535         { "Z", TR1_SLAY_ANIMAL, 1, 0 },
1536         { NULL, 0, 0, 0 }
1537 };
1538
1539 static flag_insc_table flag_insc_sust[] =
1540 {
1541         { "St", TR2_SUST_STR, 2, 0 },
1542         { "In", TR2_SUST_INT, 2, 0 },
1543         { "Wi", TR2_SUST_WIS, 2, 0 },
1544         { "Dx", TR2_SUST_DEX, 2, 0 },
1545         { "Cn", TR2_SUST_CON, 2, 0 },
1546         { "Ch", TR2_SUST_CHR, 2, 0 },
1547         { NULL, 0, 0, 0 }
1548 };
1549 #endif
1550
1551 #define ADD_INSC(STR) (void)(strcat(ptr, (STR)), ptr += strlen(STR))
1552
1553 static char *inscribe_flags_aux(flag_insc_table *f_ptr, u32b flag[], bool kanji, char *ptr)
1554 {
1555         while (f_ptr->num)
1556         {
1557                 if ((flag[f_ptr->num-1] & f_ptr->flag) &&
1558                     !(flag[f_ptr->num-1] & f_ptr->except_flag))
1559 #ifdef JP
1560                         ADD_INSC(kanji ? f_ptr->japanese : f_ptr->english);
1561 #else
1562                         ADD_INSC(f_ptr->english);
1563 #endif
1564                 f_ptr ++;
1565         }
1566
1567         return ptr;
1568 }
1569
1570 static bool have_flag_of(flag_insc_table *f_ptr, u32b flag[])
1571 {
1572         while (f_ptr->num)
1573         {
1574                 if ((flag[f_ptr->num-1] & f_ptr->flag) &&
1575                     !(flag[f_ptr->num-1] & f_ptr->except_flag))
1576                         return (TRUE);
1577                 f_ptr++;
1578         }
1579
1580         return (FALSE);
1581 }
1582
1583 s16b inscribe_flags(object_type *o_ptr, cptr out_val)
1584 {
1585         char buff[1024];
1586         char *ptr = buff;
1587         char *prev_ptr = buff;
1588         int i;
1589
1590         bool kanji = FALSE;
1591         bool all = TRUE;
1592         u32b flag[3];
1593
1594         /* not fully identified */
1595         if (!(o_ptr->ident & IDENT_MENTAL))
1596                 return quark_add(out_val);
1597
1598         /* Extract the flags */
1599         object_flags(o_ptr, &flag[0], &flag[1], &flag[2]);
1600
1601
1602         *buff = '\0';
1603         for (i = 0; out_val[i]; i++)
1604         {
1605                 if ('%' == out_val[i] )
1606                 {
1607                         cptr start_percent = ptr;
1608 #ifdef JP
1609                         if ('%' == out_val[i+1])
1610                         {
1611                                 i++;
1612                                 kanji = FALSE;
1613                         }
1614                         else
1615                         {
1616                                 kanji = TRUE;
1617                         }
1618 #endif
1619                         if ('a' == out_val[i+1] && 'l' == out_val[i+2] && 'l' == out_val[i+3])
1620                         {
1621                                 all = TRUE;
1622                                 i += 3;
1623                         }
1624                         else
1625                         {
1626                                 all = FALSE;
1627                         }
1628
1629                         /* check for too long inscription */
1630                         if (ptr >= buff + MAX_NLEN) continue;
1631
1632                         /* Remove obvious flags */
1633                         if (!all)
1634                         {
1635                                 object_kind *k_ptr = &k_info[o_ptr->k_idx];
1636                                 
1637                                 /* Base object */
1638                                 flag[0] &= ~k_ptr->flags1;
1639                                 flag[1] &= ~k_ptr->flags2;
1640                                 flag[2] &= ~k_ptr->flags3;
1641
1642                                 if (o_ptr->name1)
1643                                 {
1644                                         artifact_type *a_ptr = &a_info[o_ptr->name1];
1645                                         
1646                                         flag[0] &= ~a_ptr->flags1;
1647                                         flag[1] &= ~a_ptr->flags2;
1648                                         flag[2] &= ~(a_ptr->flags3 & ~TR3_TELEPORT);
1649                                 }
1650
1651                                 if (o_ptr->name2)
1652                                 {
1653                                         ego_item_type *e_ptr = &e_info[o_ptr->name2];
1654                                         
1655                                         flag[0] &= ~e_ptr->flags1;
1656                                         flag[1] &= ~e_ptr->flags2;
1657                                         flag[2] &= ~(e_ptr->flags3 & ~TR3_TELEPORT);
1658                                 }
1659                         }
1660
1661
1662                         /* Plusses */
1663                         if (have_flag_of(flag_insc_plus, flag))
1664                         {
1665                                 if (kanji)
1666                                         ADD_INSC("+");
1667                         }
1668                         ptr = inscribe_flags_aux(flag_insc_plus, flag, kanji, ptr);
1669
1670                         /* Immunity */
1671                         if (have_flag_of(flag_insc_immune, flag))
1672                         {
1673                                 if (!kanji && ptr != prev_ptr)
1674                                 {
1675                                         ADD_INSC(";");
1676                                         prev_ptr = ptr;
1677                                 }
1678                                 ADD_INSC("*");
1679                         }
1680                         ptr = inscribe_flags_aux(flag_insc_immune, flag, kanji, ptr);
1681
1682                         /* Resistance */
1683                         if (have_flag_of(flag_insc_resistance, flag))
1684                         {
1685                                 if (kanji)
1686                                         ADD_INSC("r");
1687                                 else if (ptr != prev_ptr)
1688                                 {
1689                                         ADD_INSC(";");
1690                                         prev_ptr = ptr;
1691                                 }
1692                         }
1693                         ptr = inscribe_flags_aux(flag_insc_resistance, flag, kanji, ptr);
1694
1695                         /* Misc Ability */
1696                         if (have_flag_of(flag_insc_misc, flag))
1697                         {
1698                                 if (ptr != prev_ptr)
1699                                 {
1700                                         ADD_INSC(";");
1701                                         prev_ptr = ptr;
1702                                 }
1703                         }
1704                         ptr = inscribe_flags_aux(flag_insc_misc, flag, kanji, ptr);
1705
1706                         /* Aura */
1707                         if (have_flag_of(flag_insc_aura, flag))
1708                         {
1709                                 ADD_INSC("[");
1710                         }
1711                         ptr = inscribe_flags_aux(flag_insc_aura, flag, kanji, ptr);
1712
1713                         /* Brand Weapon */
1714                         if (have_flag_of(flag_insc_brand, flag))
1715                                 ADD_INSC("|");
1716                         ptr = inscribe_flags_aux(flag_insc_brand, flag, kanji, ptr);
1717
1718                         /* Slay Weapon */
1719                         if (have_flag_of(flag_insc_slay, flag))
1720                                 ADD_INSC("/");
1721                         ptr = inscribe_flags_aux(flag_insc_slay, flag, kanji, ptr);
1722
1723                         /* Random Teleport */
1724                         if (flag[2] & (TR3_TELEPORT))
1725                         {
1726                                 ADD_INSC(".");
1727                         }
1728
1729                         /* sustain */
1730                         if (have_flag_of(flag_insc_sust, flag))
1731                         {
1732                                 ADD_INSC("(");
1733                         }
1734                         ptr = inscribe_flags_aux(flag_insc_sust, flag, kanji, ptr);
1735
1736                         if (ptr == start_percent)
1737                                 ADD_INSC(" ");
1738                 }
1739                 else
1740                 {
1741                         *ptr++ = out_val[i];
1742                         *ptr = '\0';
1743                 }
1744         }
1745
1746         /* cut too long inscription */
1747         if (strlen(buff) >= MAX_NLEN-1)
1748         {
1749 #ifdef JP
1750                 int n;
1751                 for (n = 0; n < MAX_NLEN; n++)
1752                         if(iskanji(buff[n])) n++;
1753                 if (n == MAX_NLEN) n = MAX_NLEN-2; /* ºÇ¸å¤¬´Á»úȾʬ */
1754                 buff[n] = '\0';
1755 #else
1756                 buff[MAX_NLEN-1] = '\0';
1757 #endif
1758         }
1759         return quark_add(buff);
1760 }
1761
1762 /*
1763  * Inscribe an object with a comment
1764  */
1765 void do_cmd_inscribe(void)
1766 {
1767         int                     item;
1768
1769         object_type             *o_ptr;
1770
1771         char            o_name[MAX_NLEN];
1772
1773         char            out_val[80];
1774
1775         cptr q, s;
1776
1777         item_tester_no_ryoute = TRUE;
1778         /* Get an item */
1779 #ifdef JP
1780         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËÌäò¹ï¤ß¤Þ¤¹¤«? ";
1781         s = "Ìäò¹ï¤á¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
1782 #else
1783         q = "Inscribe which item? ";
1784         s = "You have nothing to inscribe.";
1785 #endif
1786
1787         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1788
1789         /* Get the item (in the pack) */
1790         if (item >= 0)
1791         {
1792                 o_ptr = &inventory[item];
1793         }
1794
1795         /* Get the item (on the floor) */
1796         else
1797         {
1798                 o_ptr = &o_list[0 - item];
1799         }
1800
1801         /* Describe the activity */
1802         object_desc(o_name, o_ptr, TRUE, 2);
1803
1804         /* Message */
1805 #ifdef JP
1806         msg_format("%s¤ËÌäò¹ï¤à¡£", o_name);
1807 #else
1808         msg_format("Inscribing %s.", o_name);
1809 #endif
1810
1811         msg_print(NULL);
1812
1813         /* Start with nothing */
1814         strcpy(out_val, "");
1815
1816         /* Use old inscription */
1817         if (o_ptr->inscription)
1818         {
1819                 /* Start with the old inscription */
1820                 strcpy(out_val, quark_str(o_ptr->inscription));
1821         }
1822
1823         /* Get a new inscription (possibly empty) */
1824 #ifdef JP
1825         if (get_string("ÌÃ: ", out_val, 80))
1826 #else
1827         if (get_string("Inscription: ", out_val, 80))
1828 #endif
1829         {
1830                 /* Save the inscription */
1831                 o_ptr->inscription = inscribe_flags(o_ptr, out_val);
1832
1833                 /* Combine the pack */
1834                 p_ptr->notice |= (PN_COMBINE);
1835
1836                 /* Window stuff */
1837                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1838         }
1839 }
1840
1841
1842
1843 /*
1844  * An "item_tester_hook" for refilling lanterns
1845  */
1846 static bool item_tester_refill_lantern(object_type *o_ptr)
1847 {
1848         /* Flasks of oil are okay */
1849         if (o_ptr->tval == TV_FLASK) return (TRUE);
1850
1851         /* Laterns are okay */
1852         if ((o_ptr->tval == TV_LITE) &&
1853             (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1854
1855         /* Assume not okay */
1856         return (FALSE);
1857 }
1858
1859
1860 /*
1861  * Refill the players lamp (from the pack or floor)
1862  */
1863 static void do_cmd_refill_lamp(void)
1864 {
1865         int item;
1866
1867         object_type *o_ptr;
1868         object_type *j_ptr;
1869
1870         cptr q, s;
1871
1872
1873         /* Restrict the choices */
1874         item_tester_hook = item_tester_refill_lantern;
1875
1876         /* Get an item */
1877 #ifdef JP
1878         q = "¤É¤ÎÌý¤Ä¤Ü¤«¤éÃí¤®¤Þ¤¹¤«? ";
1879         s = "Ìý¤Ä¤Ü¤¬¤Ê¤¤¡£";
1880 #else
1881         q = "Refill with which flask? ";
1882         s = "You have no flasks of oil.";
1883 #endif
1884
1885         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1886
1887         /* Get the item (in the pack) */
1888         if (item >= 0)
1889         {
1890                 o_ptr = &inventory[item];
1891         }
1892
1893         /* Get the item (on the floor) */
1894         else
1895         {
1896                 o_ptr = &o_list[0 - item];
1897         }
1898
1899
1900         /* Take a partial turn */
1901         energy_use = 50;
1902
1903         /* Access the lantern */
1904         j_ptr = &inventory[INVEN_LITE];
1905
1906         /* Refuel */
1907         j_ptr->xtra4 += o_ptr->xtra4;
1908
1909         /* Message */
1910 #ifdef JP
1911         msg_print("¥é¥ó¥×¤ËÌý¤òÃí¤¤¤À¡£");
1912 #else
1913         msg_print("You fuel your lamp.");
1914 #endif
1915
1916         /* Comment */
1917         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1918         {
1919                 j_ptr->xtra4 = 0;
1920 #ifdef JP
1921                 msg_print("¥é¥ó¥×¤¬¾Ã¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª");
1922 #else
1923                 msg_print("Your lamp has gone out!");
1924 #endif
1925         }
1926         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1927         {
1928                 j_ptr->xtra4 = 0;
1929 #ifdef JP
1930                 msg_print("¤·¤«¤·¥é¥ó¥×¤ÏÁ´¤¯¸÷¤é¤Ê¤¤¡£");
1931 #else
1932                 msg_print("Curiously, your lamp doesn't light.");
1933 #endif
1934         }
1935         else if (j_ptr->xtra4 >= FUEL_LAMP)
1936         {
1937                 j_ptr->xtra4 = FUEL_LAMP;
1938 #ifdef JP
1939                 msg_print("¥é¥ó¥×¤ÎÌý¤Ï°ìÇÕ¤À¡£");
1940 #else
1941                 msg_print("Your lamp is full.");
1942 #endif
1943
1944         }
1945
1946         /* Decrease the item (from the pack) */
1947         if (item >= 0)
1948         {
1949                 inven_item_increase(item, -1);
1950                 inven_item_describe(item);
1951                 inven_item_optimize(item);
1952         }
1953
1954         /* Decrease the item (from the floor) */
1955         else
1956         {
1957                 floor_item_increase(0 - item, -1);
1958                 floor_item_describe(0 - item);
1959                 floor_item_optimize(0 - item);
1960         }
1961
1962         /* Recalculate torch */
1963         p_ptr->update |= (PU_TORCH);
1964 }
1965
1966
1967 /*
1968  * An "item_tester_hook" for refilling torches
1969  */
1970 static bool item_tester_refill_torch(object_type *o_ptr)
1971 {
1972         /* Torches are okay */
1973         if ((o_ptr->tval == TV_LITE) &&
1974             (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1975
1976         /* Assume not okay */
1977         return (FALSE);
1978 }
1979
1980
1981 /*
1982  * Refuel the players torch (from the pack or floor)
1983  */
1984 static void do_cmd_refill_torch(void)
1985 {
1986         int item;
1987
1988         object_type *o_ptr;
1989         object_type *j_ptr;
1990
1991         cptr q, s;
1992
1993
1994         /* Restrict the choices */
1995         item_tester_hook = item_tester_refill_torch;
1996
1997         /* Get an item */
1998 #ifdef JP
1999         q = "¤É¤Î¾¾ÌÀ¤ÇÌÀ¤«¤ê¤ò¶¯¤á¤Þ¤¹¤«? ";
2000         s = "¾¤Ë¾¾ÌÀ¤¬¤Ê¤¤¡£";
2001 #else
2002         q = "Refuel with which torch? ";
2003         s = "You have no extra torches.";
2004 #endif
2005
2006         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
2007
2008         /* Get the item (in the pack) */
2009         if (item >= 0)
2010         {
2011                 o_ptr = &inventory[item];
2012         }
2013
2014         /* Get the item (on the floor) */
2015         else
2016         {
2017                 o_ptr = &o_list[0 - item];
2018         }
2019
2020
2021         /* Take a partial turn */
2022         energy_use = 50;
2023
2024         /* Access the primary torch */
2025         j_ptr = &inventory[INVEN_LITE];
2026
2027         /* Refuel */
2028         j_ptr->xtra4 += o_ptr->xtra4 + 5;
2029
2030         /* Message */
2031 #ifdef JP
2032         msg_print("¾¾ÌÀ¤ò·ë¹ç¤·¤¿¡£");
2033 #else
2034         msg_print("You combine the torches.");
2035 #endif
2036
2037
2038         /* Comment */
2039         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
2040         {
2041                 j_ptr->xtra4 = 0;
2042 #ifdef JP
2043                 msg_print("¾¾ÌÀ¤¬¾Ã¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª");
2044 #else
2045                 msg_print("Your torch has gone out!");
2046 #endif
2047         }
2048         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
2049         {
2050                 j_ptr->xtra4 = 0;
2051 #ifdef JP
2052                 msg_print("¤·¤«¤·¾¾ÌÀ¤ÏÁ´¤¯¸÷¤é¤Ê¤¤¡£");
2053 #else
2054                 msg_print("Curiously, your torche don't light.");
2055 #endif
2056         }
2057         /* Over-fuel message */
2058         else if (j_ptr->xtra4 >= FUEL_TORCH)
2059         {
2060                 j_ptr->xtra4 = FUEL_TORCH;
2061 #ifdef JP
2062                 msg_print("¾¾ÌÀ¤Î¼÷Ì¿¤Ï½½Ê¬¤À¡£");
2063 #else
2064                 msg_print("Your torch is fully fueled.");
2065 #endif
2066
2067         }
2068
2069         /* Refuel message */
2070         else
2071         {
2072 #ifdef JP
2073                 msg_print("¾¾ÌÀ¤Ï¤¤¤Ã¤½¤¦ÌÀ¤ë¤¯µ±¤¤¤¿¡£");
2074 #else
2075                 msg_print("Your torch glows more brightly.");
2076 #endif
2077
2078         }
2079
2080         /* Decrease the item (from the pack) */
2081         if (item >= 0)
2082         {
2083                 inven_item_increase(item, -1);
2084                 inven_item_describe(item);
2085                 inven_item_optimize(item);
2086         }
2087
2088         /* Decrease the item (from the floor) */
2089         else
2090         {
2091                 floor_item_increase(0 - item, -1);
2092                 floor_item_describe(0 - item);
2093                 floor_item_optimize(0 - item);
2094         }
2095
2096         /* Recalculate torch */
2097         p_ptr->update |= (PU_TORCH);
2098 }
2099
2100
2101 /*
2102  * Refill the players lamp, or restock his torches
2103  */
2104 void do_cmd_refill(void)
2105 {
2106         object_type *o_ptr;
2107
2108         /* Get the light */
2109         o_ptr = &inventory[INVEN_LITE];
2110
2111         if (p_ptr->special_defense & KATA_MUSOU)
2112         {
2113                 set_action(ACTION_NONE);
2114         }
2115
2116         /* It is nothing */
2117         if (o_ptr->tval != TV_LITE)
2118         {
2119 #ifdef JP
2120                 msg_print("¸÷¸»¤òÁõÈ÷¤·¤Æ¤¤¤Ê¤¤¡£");
2121 #else
2122                 msg_print("You are not wielding a light.");
2123 #endif
2124
2125         }
2126
2127         /* It's a lamp */
2128         else if (o_ptr->sval == SV_LITE_LANTERN)
2129         {
2130                 do_cmd_refill_lamp();
2131         }
2132
2133         /* It's a torch */
2134         else if (o_ptr->sval == SV_LITE_TORCH)
2135         {
2136                 do_cmd_refill_torch();
2137         }
2138
2139         /* No torch to refill */
2140         else
2141         {
2142 #ifdef JP
2143                 msg_print("¤³¤Î¸÷¸»¤Ï¼÷Ì¿¤ò±ä¤Ð¤»¤Ê¤¤¡£");
2144 #else
2145                 msg_print("Your light cannot be refilled.");
2146 #endif
2147
2148         }
2149 }
2150
2151
2152 /*
2153  * Target command
2154  */
2155 void do_cmd_target(void)
2156 {
2157         /* Target set */
2158         if (target_set(TARGET_KILL))
2159         {
2160 #ifdef JP
2161                 msg_print("¥¿¡¼¥²¥Ã¥È·èÄê¡£");
2162 #else
2163                 msg_print("Target Selected.");
2164 #endif
2165
2166         }
2167
2168         /* Target aborted */
2169         else
2170         {
2171 #ifdef JP
2172                 msg_print("¥¿¡¼¥²¥Ã¥È²ò½ü¡£");
2173 #else
2174                 msg_print("Target Aborted.");
2175 #endif
2176
2177         }
2178 }
2179
2180
2181
2182 /*
2183  * Look command
2184  */
2185 void do_cmd_look(void)
2186 {
2187         /* Look around */
2188         if (target_set(TARGET_LOOK))
2189         {
2190 #ifdef JP
2191                 msg_print("¥¿¡¼¥²¥Ã¥È·èÄê¡£");
2192 #else
2193                 msg_print("Target Selected.");
2194 #endif
2195
2196         }
2197 }
2198
2199
2200
2201 /*
2202  * Allow the player to examine other sectors on the map
2203  */
2204 void do_cmd_locate(void)
2205 {
2206         int             dir, y1, x1, y2, x2;
2207
2208         char    tmp_val[80];
2209
2210         char    out_val[160];
2211
2212         int wid, hgt;
2213
2214         /* Get size */
2215         get_screen_size(&wid, &hgt);
2216
2217
2218         /* Start at current panel */
2219         y2 = y1 = panel_row_min;
2220         x2 = x1 = panel_col_min;
2221
2222         /* Show panels until done */
2223         while (1)
2224         {
2225                 /* Describe the location */
2226                 if ((y2 == y1) && (x2 == x1))
2227                 {
2228 #ifdef JP
2229                         strcpy(tmp_val, "¿¿¾å");
2230 #else
2231                         tmp_val[0] = '\0';
2232 #endif
2233
2234                 }
2235                 else
2236                 {
2237 #ifdef JP
2238                         sprintf(tmp_val, "%s%s",
2239                                 ((y2 < y1) ? "ËÌ" : (y2 > y1) ? "Æî" : ""),
2240                                 ((x2 < x1) ? "À¾" : (x2 > x1) ? "Åì" : ""));
2241 #else
2242                         sprintf(tmp_val, "%s%s of",
2243                                 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
2244                                 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
2245 #endif
2246
2247                 }
2248
2249                 /* Prepare to ask which way to look */
2250                 sprintf(out_val,
2251 #ifdef JP
2252                         "¥Þ¥Ã¥×°ÌÃÖ [%d(%02d),%d(%02d)] (¥×¥ì¥¤¥ä¡¼¤Î%s)  Êý¸þ?",
2253 #else
2254                         "Map sector [%d(%02d),%d(%02d)], which is%s your sector.  Direction?",
2255 #endif
2256
2257                         y2 / (hgt / 2), y2 % (hgt / 2),
2258                         x2 / (wid / 2), x2 % (wid / 2), tmp_val);
2259
2260                 /* Assume no direction */
2261                 dir = 0;
2262
2263                 /* Get a direction */
2264                 while (!dir)
2265                 {
2266                         char command;
2267
2268                         /* Get a command (or Cancel) */
2269                         if (!get_com(out_val, &command, TRUE)) break;
2270
2271                         /* Extract the action (if any) */
2272                         dir = get_keymap_dir(command);
2273
2274                         /* Error */
2275                         if (!dir) bell();
2276                 }
2277
2278                 /* No direction */
2279                 if (!dir) break;
2280
2281                 /* Apply the motion */
2282                 if (change_panel(ddy[dir], ddx[dir]))
2283                 {
2284                         y2 = panel_row_min;
2285                         x2 = panel_col_min;
2286                 }
2287         }
2288
2289
2290         /* Recenter the map around the player */
2291         verify_panel();
2292
2293         /* Update stuff */
2294         p_ptr->update |= (PU_MONSTERS);
2295
2296         /* Redraw map */
2297         p_ptr->redraw |= (PR_MAP);
2298
2299         /* Window stuff */
2300         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2301
2302         /* Handle stuff */
2303         handle_stuff();
2304 }
2305
2306
2307
2308 /*
2309  * The table of "symbol info" -- each entry is a string of the form
2310  * "X:desc" where "X" is the trigger, and "desc" is the "info".
2311  */
2312 static cptr ident_info[] =
2313 {
2314 #ifdef JP
2315         " :°Å°Ç",
2316         "!:Ìô, ¥ª¥¤¥ë",
2317         "\":¥¢¥ß¥å¥ì¥Ã¥È, ðô¾þ¤ê",
2318         "#:ÊÉ(±£¤·¥É¥¢)Ëô¤Ï¿¢Êª",
2319         "$:ºâÊõ(¶â¤«ÊõÀÐ)",
2320         "%:¹ÛÌ®(Íϴ䤫ÀбÑ)",
2321         "&:Ȣ",
2322         "':³«¤¤¤¿¥É¥¢",
2323         "(:Æð¤é¤«¤¤Ëɶñ",
2324         "):½â",
2325         "*:ºâÊõ¤ò´Þ¤ó¤À¹ÛÌ®¤Þ¤¿¤Ïµå·Á¤Î²øʪ",
2326         "+:ÊĤ¸¤¿¥É¥¢",
2327         ",:¿©¤Ùʪ, ¤ª¤Ð¤±¥­¥Î¥³",
2328         "-:ËâË¡ËÀ, ¥í¥Ã¥É",
2329         ".:¾²",
2330         "/:´È¾õÉð´ï(¥¢¥Ã¥¯¥¹/¥Ñ¥¤¥¯/Åù)",
2331         "0:Çîʪ´Û¤ÎÆþ¸ý",
2332         "1:»¨²ß²°¤ÎÆþ¸ý",
2333         "2:Ëɶñ²°¤ÎÆþ¸ý",
2334         "3:Éð´ïÀìÌ珤ÎÆþ¸ý",
2335         "4:»û±¡¤ÎÆþ¸ý",
2336         "5:Ï£¶â½Ñ¤ÎŹ¤ÎÆþ¸ý",
2337         "6:ËâË¡¤ÎŹ¤ÎÆþ¸ý",
2338         "7:¥Ö¥é¥Ã¥¯¥Þ¡¼¥±¥Ã¥È¤ÎÆþ¸ý",
2339         "8:²æ¤¬²È¤ÎÆþ¸ý",
2340         "9:½ñŹ¤ÎÆþ¸ý",
2341         "::´äÀÐ",
2342         ";:²óÈò¤Î³¨Ê¸»ú/Çúȯ¤Î¥ë¡¼¥ó",
2343         "<:¾å¤ê³¬ÃÊ",
2344         "=:»ØÎØ",
2345         ">:²¼¤ê³¬ÃÊ",
2346         "?:´¬Êª",
2347         "@:¥×¥ì¥¤¥ä¡¼",
2348         "A:Å·»È",
2349         "B:Ļ",
2350         "C:¸¤",
2351         "D:¸ÅÂå¥É¥é¥´¥ó/¥ï¥¤¥¢¡¼¥à",
2352         "E:¥¨¥ì¥á¥ó¥¿¥ë",
2353         "F:¥È¥ó¥Ü",
2354         "G:¥´¡¼¥¹¥È",
2355         "H:»¨¼ï",
2356         "I:º«Ãî",
2357         "J:¥Ø¥Ó",
2358         "K:¥­¥é¡¼¡¦¥Ó¡¼¥È¥ë",
2359         "L:¥ê¥Ã¥Á",
2360         "M:¿¼ó¤Îà¨ÃîÎà",
2361         "N:Ææ¤ÎÀ¸Êª",
2362         "O:¥ª¡¼¥¬",
2363         "P:µðÂç¿Í´Ö·¿À¸Êª",
2364         "Q:¥¯¥¤¥ë¥¹¥ë¥°(Ì®ÂǤÄÆù²ô)",
2365         "R:à¨ÃîÎà/ξÀ¸Îà",
2366         "S:ÃØéá/¥µ¥½¥ê/¥À¥Ë",
2367         "T:¥È¥í¥ë",
2368         "U:¾åµé¥Ç¡¼¥â¥ó",
2369         "V:¥Ð¥ó¥Ñ¥¤¥¢",
2370         "W:¥ï¥¤¥È/¥ì¥¤¥¹/Åù",
2371         "X:¥¾¡¼¥ó/¥¶¥ì¥ó/Åù",
2372         "Y:¥¤¥¨¥Æ¥£",
2373         "Z:¥Ï¥¦¥ó¥É",
2374         "[:·ø¤¤¥¢¡¼¥Þ¡¼",
2375         "\\:Æß´ï(¥á¥¤¥¹/¥à¥Á/Åù)",
2376         "]:¼ï¡¹¤ÎËɶñ",
2377         "^:¥È¥é¥Ã¥×",
2378         "_:¾ó",
2379         "`:¿Í·Á¡¤Ä¦Áü",
2380         "a:¥¢¥ê",
2381         "b:¥³¥¦¥â¥ê",
2382         "c:¥à¥«¥Ç",
2383         "d:¥É¥é¥´¥ó",
2384         "e:ÌܶÌ",
2385         "f:¥Í¥³",
2386         "g:¥´¡¼¥ì¥à",
2387         "h:¥Û¥Ó¥Ã¥È/¥¨¥ë¥Õ/¥É¥ï¡¼¥Õ",
2388         "i:¥Ù¥È¥Ù¥È",
2389         "j:¥¼¥ê¡¼",
2390         "k:¥³¥Ü¥ë¥É",
2391         "l:¿åÀ³À¸Êª",
2392         "m:¥â¥ë¥É",
2393         "n:¥Ê¡¼¥¬",
2394         "o:¥ª¡¼¥¯",
2395         "p:¿Í´Ö",
2396         "q:»Í­½Ã",
2397         "r:¥Í¥º¥ß",
2398         "s:¥¹¥±¥ë¥È¥ó",
2399         "t:Ä®¤Î¿Í",
2400         "u:²¼µé¥Ç¡¼¥â¥ó",
2401         "v:¥Ü¥ë¥Æ¥Ã¥¯¥¹",
2402         "w:¥¤¥â¥à¥·/Âç·²",
2403         /* "x:unused", */
2404         "y:¥¤¡¼¥¯",
2405         "z:¥¾¥ó¥Ó/¥ß¥¤¥é",
2406         "{:Èô¤ÓÆ»¶ñ¤ÎÃÆ(Ìð/ÃÆ)",
2407         "|:Åá·õÎà(¥½¡¼¥É/¥À¥¬¡¼/Åù)",
2408         "}:Èô¤ÓÆ»¶ñ(µÝ/¥¯¥í¥¹¥Ü¥¦/¥¹¥ê¥ó¥°)",
2409         "~:¿å/ÍÏ´äή(¼ï¡¹¤Î¥¢¥¤¥Æ¥à)",
2410 #else
2411         " :A dark grid",
2412         "!:A potion (or oil)",
2413         "\":An amulet (or necklace)",
2414         "#:A wall (or secret door)",
2415         "$:Treasure (gold or gems)",
2416         "%:A vein (magma or quartz)",
2417         "&:A chest",
2418         "':An open door",
2419         "(:Soft armor",
2420         "):A shield",
2421         "*:A vein with treasure or a ball monster",
2422         "+:A closed door",
2423         ",:Food (or mushroom patch)",
2424         "-:A wand (or rod)",
2425         ".:Floor",
2426         "/:A polearm (Axe/Pike/etc)",
2427         "0:Entrance to Museum",
2428         "1:Entrance to General Store",
2429         "2:Entrance to Armory",
2430         "3:Entrance to Weaponsmith",
2431         "4:Entrance to Temple",
2432         "5:Entrance to Alchemy shop",
2433         "6:Entrance to Magic store",
2434         "7:Entrance to Black Market",
2435         "8:Entrance to your home",
2436         "9:Entrance to the bookstore",
2437         "::Rubble",
2438         ";:A glyph of warding / explosive rune",
2439         "<:An up staircase",
2440         "=:A ring",
2441         ">:A down staircase",
2442         "?:A scroll",
2443         "@:You",
2444         "A:Angel",
2445         "B:Bird",
2446         "C:Canine",
2447         "D:Ancient Dragon/Wyrm",
2448         "E:Elemental",
2449         "F:Dragon Fly",
2450         "G:Ghost",
2451         "H:Hybrid",
2452         "I:Insect",
2453         "J:Snake",
2454         "K:Killer Beetle",
2455         "L:Lich",
2456         "M:Multi-Headed Reptile",
2457         "N:Mystery Living",
2458         "O:Ogre",
2459         "P:Giant Humanoid",
2460         "Q:Quylthulg (Pulsing Flesh Mound)",
2461         "R:Reptile/Amphibian",
2462         "S:Spider/Scorpion/Tick",
2463         "T:Troll",
2464         "U:Major Demon",
2465         "V:Vampire",
2466         "W:Wight/Wraith/etc",
2467         "X:Xorn/Xaren/etc",
2468         "Y:Yeti",
2469         "Z:Zephyr Hound",
2470         "[:Hard armor",
2471         "\\:A hafted weapon (mace/whip/etc)",
2472         "]:Misc. armor",
2473         "^:A trap",
2474         "_:A staff",
2475         "`:A figurine or statue",
2476         "a:Ant",
2477         "b:Bat",
2478         "c:Centipede",
2479         "d:Dragon",
2480         "e:Floating Eye",
2481         "f:Feline",
2482         "g:Golem",
2483         "h:Hobbit/Elf/Dwarf",
2484         "i:Icky Thing",
2485         "j:Jelly",
2486         "k:Kobold",
2487         "l:Aquatic monster",
2488         "m:Mold",
2489         "n:Naga",
2490         "o:Orc",
2491         "p:Person/Human",
2492         "q:Quadruped",
2493         "r:Rodent",
2494         "s:Skeleton",
2495         "t:Townsperson",
2496         "u:Minor Demon",
2497         "v:Vortex",
2498         "w:Worm/Worm-Mass",
2499         /* "x:unused", */
2500         "y:Yeek",
2501         "z:Zombie/Mummy",
2502         "{:A missile (arrow/bolt/shot)",
2503         "|:An edged weapon (sword/dagger/etc)",
2504         "}:A launcher (bow/crossbow/sling)",
2505         "~:Fluid terrain (or miscellaneous item)",
2506 #endif
2507
2508         NULL
2509 };
2510
2511
2512 /*
2513  * Sorting hook -- Comp function -- see below
2514  *
2515  * We use "u" to point to array of monster indexes,
2516  * and "v" to select the type of sorting to perform on "u".
2517  */
2518 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
2519 {
2520         u16b *who = (u16b*)(u);
2521
2522         u16b *why = (u16b*)(v);
2523
2524         int w1 = who[a];
2525         int w2 = who[b];
2526
2527         int z1, z2;
2528
2529
2530         /* Sort by player kills */
2531         if (*why >= 4)
2532         {
2533                 /* Extract player kills */
2534                 z1 = r_info[w1].r_pkills;
2535                 z2 = r_info[w2].r_pkills;
2536
2537                 /* Compare player kills */
2538                 if (z1 < z2) return (TRUE);
2539                 if (z1 > z2) return (FALSE);
2540         }
2541
2542
2543         /* Sort by total kills */
2544         if (*why >= 3)
2545         {
2546                 /* Extract total kills */
2547                 z1 = r_info[w1].r_tkills;
2548                 z2 = r_info[w2].r_tkills;
2549
2550                 /* Compare total kills */
2551                 if (z1 < z2) return (TRUE);
2552                 if (z1 > z2) return (FALSE);
2553         }
2554
2555
2556         /* Sort by monster level */
2557         if (*why >= 2)
2558         {
2559                 /* Extract levels */
2560                 z1 = r_info[w1].level;
2561                 z2 = r_info[w2].level;
2562
2563                 /* Compare levels */
2564                 if (z1 < z2) return (TRUE);
2565                 if (z1 > z2) return (FALSE);
2566         }
2567
2568
2569         /* Sort by monster experience */
2570         if (*why >= 1)
2571         {
2572                 /* Extract experience */
2573                 z1 = r_info[w1].mexp;
2574                 z2 = r_info[w2].mexp;
2575
2576                 /* Compare experience */
2577                 if (z1 < z2) return (TRUE);
2578                 if (z1 > z2) return (FALSE);
2579         }
2580
2581
2582         /* Compare indexes */
2583         return (w1 <= w2);
2584 }
2585
2586
2587 /*
2588  * Sorting hook -- Swap function -- see below
2589  *
2590  * We use "u" to point to array of monster indexes,
2591  * and "v" to select the type of sorting to perform.
2592  */
2593 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
2594 {
2595         u16b *who = (u16b*)(u);
2596
2597         u16b holder;
2598
2599         /* Swap */
2600         holder = who[a];
2601         who[a] = who[b];
2602         who[b] = holder;
2603 }
2604
2605
2606
2607 /*
2608  * Identify a character, allow recall of monsters
2609  *
2610  * Several "special" responses recall "multiple" monsters:
2611  *   ^A (all monsters)
2612  *   ^U (all unique monsters)
2613  *   ^N (all non-unique monsters)
2614  *
2615  * The responses may be sorted in several ways, see below.
2616  *
2617  * Note that the player ghosts are ignored. XXX XXX XXX
2618  */
2619 void do_cmd_query_symbol(void)
2620 {
2621         int             i, n, r_idx;
2622         char    sym, query;
2623         char    buf[128];
2624
2625         bool    all = FALSE;
2626         bool    uniq = FALSE;
2627         bool    norm = FALSE;
2628         char    temp[80] = "";
2629
2630         bool    recall = FALSE;
2631
2632         u16b    why = 0;
2633         u16b    *who;
2634
2635         /* Get a character, or abort */
2636 #ifdef JP
2637         if (!get_com("ÃΤꤿ¤¤Ê¸»ú¤òÆþÎϤ·¤Æ²¼¤µ¤¤(µ­¹æ or ^AÁ´,^U¥æ,^NÈó¥æ,^M̾Á°): ", &sym, FALSE)) return;
2638 #else
2639         if (!get_com("Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ", &sym, FALSE)) return;
2640 #endif
2641
2642
2643         /* Find that character info, and describe it */
2644         for (i = 0; ident_info[i]; ++i)
2645         {
2646                 if (sym == ident_info[i][0]) break;
2647         }
2648
2649         /* Describe */
2650         if (sym == KTRL('A'))
2651         {
2652                 all = TRUE;
2653 #ifdef JP
2654                 strcpy(buf, "Á´¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2655 #else
2656                 strcpy(buf, "Full monster list.");
2657 #endif
2658
2659         }
2660         else if (sym == KTRL('U'))
2661         {
2662                 all = uniq = TRUE;
2663 #ifdef JP
2664                 strcpy(buf, "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2665 #else
2666                 strcpy(buf, "Unique monster list.");
2667 #endif
2668
2669         }
2670         else if (sym == KTRL('N'))
2671         {
2672                 all = norm = TRUE;
2673 #ifdef JP
2674                 strcpy(buf, "¥æ¥Ë¡¼¥¯³°¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2675 #else
2676                 strcpy(buf, "Non-unique monster list.");
2677 #endif
2678
2679         }
2680         /* XTRA HACK WHATSEARCH */
2681         else if (sym == KTRL('M'))
2682         {
2683                 all = TRUE;
2684 #ifdef JP
2685                 if (!get_string("̾Á°(±Ñ¸ì¤Î¾ì¹ç¾®Ê¸»ú¤Ç²Ä)",temp, 70))
2686 #else
2687                 if (!get_string("Enter name:",temp, 70))
2688 #endif
2689                 {
2690                         temp[0]=0;
2691                         return;
2692                 }
2693 #ifdef JP
2694                 sprintf(buf, "̾Á°:%s¤Ë¥Þ¥Ã¥Á",temp);
2695 #else
2696                 sprintf(buf, "Monsters with a name \"%s\"",temp);
2697 #endif
2698         }
2699         else if (ident_info[i])
2700         {
2701                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
2702         }
2703         else
2704         {
2705 #ifdef JP
2706                 sprintf(buf, "%c - %s", sym, "̵¸ú¤Êʸ»ú");
2707 #else
2708                 sprintf(buf, "%c - %s.", sym, "Unknown Symbol");
2709 #endif
2710
2711         }
2712
2713         /* Display the result */
2714         prt(buf, 0, 0);
2715
2716         /* Allocate the "who" array */
2717         C_MAKE(who, max_r_idx, u16b);
2718
2719         /* Collect matching monsters */
2720         for (n = 0, i = 1; i < max_r_idx; i++)
2721         {
2722                 monster_race *r_ptr = &r_info[i];
2723
2724                 /* Nothing to recall */
2725                 if (!cheat_know && !r_ptr->r_sights) continue;
2726
2727                 /* Require non-unique monsters if needed */
2728                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
2729
2730                 /* Require unique monsters if needed */
2731                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
2732
2733                 /* XTRA HACK WHATSEARCH */
2734                 if (temp[0]){
2735                   int xx;
2736                   char temp2[80];
2737   
2738                   for (xx=0; temp[xx] && xx<80; xx++){
2739 #ifdef JP
2740                     if (iskanji( temp[xx])) { xx++; continue; }
2741 #endif
2742                     if (isupper(temp[xx])) temp[xx]=tolower(temp[xx]);
2743                   }
2744   
2745 #ifdef JP
2746                   strcpy(temp2, r_name+r_ptr->E_name);
2747 #else
2748                   strcpy(temp2, r_name+r_ptr->name);
2749 #endif
2750                   for (xx=0; temp2[xx] && xx<80; xx++)
2751                     if (isupper(temp2[xx])) temp2[xx]=tolower(temp2[xx]);
2752   
2753 #ifdef JP
2754                   if (strstr(temp2, temp) || strstr_j(r_name + r_ptr->name, temp) )
2755 #else
2756                   if (strstr(temp2, temp))
2757 #endif
2758                           who[n++]=i;
2759                 }else
2760                 /* Collect "appropriate" monsters */
2761                 if (all || (r_ptr->d_char == sym)) who[n++] = i;
2762         }
2763
2764         /* Nothing to recall */
2765         if (!n)
2766         {
2767                 /* Free the "who" array */
2768                 C_KILL(who, max_r_idx, u16b);
2769
2770                 return;
2771         }
2772
2773
2774         /* Prompt XXX XXX XXX */
2775 #ifdef JP
2776         put_str("»×¤¤½Ð¤ò¸«¤Þ¤¹¤«? (k:»¦³²½ç/y/n): ", 0, 36);
2777 #else
2778         put_str("Recall details? (k/y/n): ", 0, 40);
2779 #endif
2780
2781
2782         /* Query */
2783         query = inkey();
2784
2785         /* Restore */
2786         prt(buf, 0, 0);
2787
2788         why = 2;
2789
2790         /* Select the sort method */
2791         ang_sort_comp = ang_sort_comp_hook;
2792         ang_sort_swap = ang_sort_swap_hook;
2793
2794         /* Sort the array */
2795         ang_sort(who, &why, n);
2796
2797         /* Sort by kills (and level) */
2798         if (query == 'k')
2799         {
2800                 why = 4;
2801                 query = 'y';
2802         }
2803
2804         /* Catch "escape" */
2805         if (query != 'y')
2806         {
2807                 /* Free the "who" array */
2808                 C_KILL(who, max_r_idx, u16b);
2809
2810                 return;
2811         }
2812
2813         /* Sort if needed */
2814         if (why == 4)
2815         {
2816                 /* Select the sort method */
2817                 ang_sort_comp = ang_sort_comp_hook;
2818                 ang_sort_swap = ang_sort_swap_hook;
2819
2820                 /* Sort the array */
2821                 ang_sort(who, &why, n);
2822         }
2823
2824
2825         /* Start at the end */
2826         i = n - 1;
2827
2828         /* Scan the monster memory */
2829         while (1)
2830         {
2831                 /* Extract a race */
2832                 r_idx = who[i];
2833
2834                 /* Hack -- Auto-recall */
2835                 monster_race_track(FALSE, r_idx);
2836
2837                 /* Hack -- Handle stuff */
2838                 handle_stuff();
2839
2840                 /* Hack -- Begin the prompt */
2841                 roff_top(r_idx);
2842
2843                 /* Hack -- Complete the prompt */
2844 #ifdef JP
2845                 Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ESC]");
2846 #else
2847                 Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]");
2848 #endif
2849
2850
2851                 /* Interact */
2852                 while (1)
2853                 {
2854                         /* Recall */
2855                         if (recall)
2856                         {
2857                                 /* Save the screen */
2858                                 screen_save();
2859
2860                                 /* Recall on screen */
2861                                 screen_roff(who[i], 0);
2862
2863                                 /* Hack -- Complete the prompt (again) */
2864 #ifdef JP
2865                                 Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ESC]");
2866 #else
2867                                 Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]");
2868 #endif
2869
2870                         }
2871
2872                         /* Command */
2873                         query = inkey();
2874
2875                         /* Unrecall */
2876                         if (recall)
2877                         {
2878                                 /* Restore */
2879                                 screen_load();
2880                         }
2881
2882                         /* Normal commands */
2883                         if (query != 'r') break;
2884
2885                         /* Toggle recall */
2886                         recall = !recall;
2887                 }
2888
2889                 /* Stop scanning */
2890                 if (query == ESCAPE) break;
2891
2892                 /* Move to "prev" monster */
2893                 if (query == '-')
2894                 {
2895                         if (++i == n)
2896                         {
2897                                 i = 0;
2898                                 if (!expand_list) break;
2899                         }
2900                 }
2901
2902                 /* Move to "next" monster */
2903                 else
2904                 {
2905                         if (i-- == 0)
2906                         {
2907                                 i = n - 1;
2908                                 if (!expand_list) break;
2909                         }
2910                 }
2911         }
2912
2913         /* Free the "who" array */
2914         C_KILL(who, max_r_idx, u16b);
2915
2916         /* Re-display the identity */
2917         prt(buf, 0, 0);
2918 }
2919
2920
2921 /*
2922  *  research_mon
2923  *  -KMW-
2924  */
2925 bool research_mon(void)
2926 {
2927         int i, n, r_idx;
2928         char sym, query;
2929         char buf[128];
2930
2931         s16b oldkills;
2932         byte oldwake;
2933         bool oldcheat;
2934
2935         bool notpicked;
2936
2937         bool recall = FALSE;
2938
2939         u16b why = 0;
2940
2941         monster_race *r2_ptr;
2942
2943         u16b    *who;
2944
2945         /* XTRA HACK WHATSEARCH */
2946         bool    all = FALSE;
2947         bool    uniq = FALSE;
2948         bool    norm = FALSE;
2949         char temp[80] = "";
2950
2951         /* XTRA HACK REMEMBER_IDX */
2952         static int old_sym = '\0';
2953         static int old_i = 0;
2954
2955         oldcheat = cheat_know;
2956
2957
2958         /* Save the screen */
2959         screen_save();
2960
2961         /* Get a character, or abort */
2962 #ifdef JP
2963 if (!get_com("¥â¥ó¥¹¥¿¡¼¤Îʸ»ú¤òÆþÎϤ·¤Æ²¼¤µ¤¤(µ­¹æ or ^AÁ´,^U¥æ,^NÈó¥æ,^M̾Á°):", &sym, FALSE)) 
2964 #else
2965         if (!get_com("Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ", &sym, FALSE))
2966 #endif
2967
2968         {
2969                 /* Restore */
2970                 screen_load();
2971
2972                 return (FALSE);
2973         }
2974
2975         /* Find that character info, and describe it */
2976         for (i = 0; ident_info[i]; ++i)
2977         {
2978                 if (sym == ident_info[i][0]) break;
2979         }
2980
2981                 /* XTRA HACK WHATSEARCH */
2982         if (sym == KTRL('A'))
2983         {
2984                 all = TRUE;
2985 #ifdef JP
2986                 strcpy(buf, "Á´¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2987 #else
2988                 strcpy(buf, "Full monster list.");
2989 #endif
2990         }
2991         else if (sym == KTRL('U'))
2992         {
2993                 all = uniq = TRUE;
2994 #ifdef JP
2995                 strcpy(buf, "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2996 #else
2997                 strcpy(buf, "Unique monster list.");
2998 #endif
2999         }
3000         else if (sym == KTRL('N'))
3001         {
3002                 all = norm = TRUE;
3003 #ifdef JP
3004                 strcpy(buf, "¥æ¥Ë¡¼¥¯³°¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
3005 #else
3006                 strcpy(buf, "Non-unique monster list.");
3007 #endif
3008         }
3009         else if (sym == KTRL('M'))
3010         {
3011                 all = TRUE;
3012 #ifdef JP
3013                 if (!get_string("̾Á°(±Ñ¸ì¤Î¾ì¹ç¾®Ê¸»ú¤Ç²Ä)",temp, 70))
3014 #else
3015                 if (!get_string("Enter name:",temp, 70))
3016 #endif
3017                 {
3018                         temp[0]=0;
3019                         return FALSE;
3020                 }
3021 #ifdef JP
3022                 sprintf(buf, "̾Á°:%s¤Ë¥Þ¥Ã¥Á",temp);
3023 #else
3024                 sprintf(buf, "Monsters with a name \"%s\"",temp);
3025 #endif
3026         }
3027         else if (ident_info[i])
3028         {
3029                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
3030         }
3031         else
3032         {
3033 #ifdef JP
3034 sprintf(buf, "%c - %s", sym, "̵¸ú¤Êʸ»ú");
3035 #else
3036                 sprintf(buf, "%c - %s.", sym, "Unknown Symbol");
3037 #endif
3038
3039         }
3040
3041         /* Display the result */
3042         prt(buf, 16, 10);
3043
3044
3045         /* Allocate the "who" array */
3046         C_MAKE(who, max_r_idx, u16b);
3047
3048         /* Collect matching monsters */
3049         for (n = 0, i = 1; i < max_r_idx; i++)
3050         {
3051                 monster_race *r_ptr = &r_info[i];
3052
3053                 cheat_know = TRUE;
3054
3055                 /* XTRA HACK WHATSEARCH */
3056                 /* Require non-unique monsters if needed */
3057                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
3058
3059                 /* Require unique monsters if needed */
3060                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
3061
3062                 /* Ì¾Á°¸¡º÷ */
3063                 if (temp[0]){
3064                   int xx;
3065                   char temp2[80];
3066   
3067                   for (xx=0; temp[xx] && xx<80; xx++){
3068 #ifdef JP
3069                     if (iskanji( temp[xx])) { xx++; continue; }
3070 #endif
3071                     if (isupper(temp[xx])) temp[xx]=tolower(temp[xx]);
3072                   }
3073   
3074 #ifdef JP
3075                   strcpy(temp2, r_name+r_ptr->E_name);
3076 #else
3077                   strcpy(temp2, r_name+r_ptr->name);
3078 #endif
3079                   for (xx=0; temp2[xx] && xx<80; xx++)
3080                     if (isupper(temp2[xx])) temp2[xx]=tolower(temp2[xx]);
3081   
3082 #ifdef JP
3083                   if (strstr(temp2, temp) || strstr_j(r_name + r_ptr->name, temp) )
3084 #else
3085                   if (strstr(temp2, temp))
3086 #endif
3087                           who[n++]=i;
3088                 }
3089                 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
3090         }
3091
3092         /* Nothing to recall */
3093         if (!n)
3094         {
3095                 cheat_know = oldcheat;
3096
3097                 /* Free the "who" array */
3098                 C_KILL(who, max_r_idx, u16b);
3099
3100                 /* Restore */
3101                 screen_load();
3102
3103                 return (FALSE);
3104         }
3105
3106         /* Sort by level */
3107         why = 2;
3108         query = 'y';
3109
3110         /* Sort if needed */
3111         if (why)
3112         {
3113                 /* Select the sort method */
3114                 ang_sort_comp = ang_sort_comp_hook;
3115                 ang_sort_swap = ang_sort_swap_hook;
3116
3117                 /* Sort the array */
3118                 ang_sort(who, &why, n);
3119         }
3120
3121
3122         /* Start at the end */
3123         /* XTRA HACK REMEMBER_IDX */
3124         if (old_sym == sym && old_i < n) i = old_i;
3125         else i = n - 1;
3126
3127         notpicked = TRUE;
3128
3129         /* Scan the monster memory */
3130         while (notpicked)
3131         {
3132                 /* Extract a race */
3133                 r_idx = who[i];
3134
3135                 /* Save this monster ID */
3136                 p_ptr->monster_race_idx = r_idx;
3137
3138                 /* Hack -- Handle stuff */
3139                 handle_stuff();
3140
3141                 /* Hack -- Begin the prompt */
3142                 roff_top(r_idx);
3143
3144                 /* Hack -- Complete the prompt */
3145 #ifdef JP
3146 Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ' '¤Ç³¹Ô, ESC]");
3147 #else
3148                 Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC, space to continue]");
3149 #endif
3150
3151
3152                 /* Interact */
3153                 while (1)
3154                 {
3155                         /* Recall */
3156                         if (recall)
3157                         {
3158                                 /* Recall on screen */
3159                                 r2_ptr = &r_info[r_idx];
3160
3161                                 oldkills = r2_ptr->r_tkills;
3162                                 oldwake = r2_ptr->r_wake;
3163                                 screen_roff(who[i], 1);
3164                                 r2_ptr->r_tkills = oldkills;
3165                                 r2_ptr->r_wake = oldwake;
3166                                 cheat_know = oldcheat;
3167                                 notpicked = FALSE;
3168
3169                                 /* XTRA HACK REMEMBER_IDX */
3170                                 old_sym = sym;
3171                                 old_i = i;
3172                         }
3173
3174                         /* Command */
3175                         query = inkey();
3176
3177                         /* Normal commands */
3178                         if (query != 'r') break;
3179
3180                         /* Toggle recall */
3181                         recall = !recall;
3182                 }
3183
3184                 /* Stop scanning */
3185                 if (query == ESCAPE) break;
3186
3187                 /* Move to "prev" monster */
3188                 if (query == '-')
3189                 {
3190                         if (++i == n)
3191                         {
3192                                 i = 0;
3193                                 if (!expand_list) break;
3194                         }
3195                 }
3196
3197                 /* Move to "next" monster */
3198                 else
3199                 {
3200                         if (i-- == 0)
3201                         {
3202                                 i = n - 1;
3203                                 if (!expand_list) break;
3204                         }
3205                 }
3206         }
3207
3208
3209         /* Re-display the identity */
3210         /* prt(buf, 5, 5);*/
3211
3212         cheat_know = oldcheat;
3213
3214         /* Free the "who" array */
3215         C_KILL(who, max_r_idx, u16b);
3216
3217         /* Restore */
3218         screen_load();
3219
3220         return (!notpicked);
3221 }
3222