OSDN Git Service

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