OSDN Git Service

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