OSDN Git Service

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