OSDN Git Service

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