OSDN Git Service

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