OSDN Git Service

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