OSDN Git Service

Initial revision
[hengband/hengband.git] / src / cmd6.c
1 /* File: cmd6.c */
2
3 /* Purpose: Object 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  * This file includes code for eating food, drinking potions,
18  * reading scrolls, aiming wands, using staffs, zapping rods,
19  * and activating artifacts.
20  *
21  * In all cases, if the player becomes "aware" of the item's use
22  * by testing it, mark it as "aware" and reward some experience
23  * based on the object's level, always rounding up.  If the player
24  * remains "unaware", mark that object "kind" as "tried".
25  *
26  * This code now correctly handles the unstacking of wands, staffs,
27  * and rods.  Note the overly paranoid warning about potential pack
28  * overflow, which allows the player to use and drop a stacked item.
29  *
30  * In all "unstacking" scenarios, the "used" object is "carried" as if
31  * the player had just picked it up.  In particular, this means that if
32  * the use of an item induces pack overflow, that item will be dropped.
33  *
34  * For simplicity, these routines induce a full "pack reorganization"
35  * which not only combines similar items, but also reorganizes various
36  * items to obey the current "sorting" method.  This may require about
37  * 400 item comparisons, but only occasionally.
38  *
39  * There may be a BIG problem with any "effect" that can cause "changes"
40  * to the inventory.  For example, a "scroll of recharging" can cause
41  * a wand/staff to "disappear", moving the inventory up.  Luckily, the
42  * scrolls all appear BEFORE the staffs/wands, so this is not a problem.
43  * But, for example, a "staff of recharging" could cause MAJOR problems.
44  * In such a case, it will be best to either (1) "postpone" the effect
45  * until the end of the function, or (2) "change" the effect, say, into
46  * giving a staff "negative" charges, or "turning a staff into a stick".
47  * It seems as though a "rod of recharging" might in fact cause problems.
48  * The basic problem is that the act of recharging (and destroying) an
49  * item causes the inducer of that action to "move", causing "o_ptr" to
50  * no longer point at the correct item, with horrifying results.
51  *
52  * Note that food/potions/scrolls no longer use bit-flags for effects,
53  * but instead use the "sval" (which is also used to sort the objects).
54  */
55
56
57 static void do_cmd_eat_food_aux(int item)
58 {
59         int ident, lev;
60         object_type *o_ptr;
61
62         /* Get the item (in the pack) */
63         if (item >= 0)
64         {
65                 o_ptr = &inventory[item];
66         }
67
68         /* Get the item (on the floor) */
69         else
70         {
71                 o_ptr = &o_list[0 - item];
72         }
73
74         /* Sound */
75         sound(SOUND_EAT);
76
77         /* Take a turn */
78         energy_use = 100;
79
80         /* Identity not known yet */
81         ident = FALSE;
82
83         /* Object level */
84         lev = get_object_level(o_ptr);
85
86 #ifdef USE_SCRIPT
87         eat_callback(o_ptr->sval);
88
89         if (!object_eat_callback(o_ptr))
90 #endif /* USE_SCRIPT */
91
92         {
93                 if (o_ptr->tval == TV_FOOD)
94                 {
95                 /* Analyze the food */
96                 switch (o_ptr->sval)
97                 {
98                         case SV_FOOD_POISON:
99                         {
100                                 if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
101                                 {
102                                         if (set_poisoned(p_ptr->poisoned + rand_int(10) + 10))
103                                         {
104                                                 ident = TRUE;
105                                         }
106                                 }
107                                 break;
108                         }
109
110                         case SV_FOOD_BLINDNESS:
111                         {
112                                 if (!p_ptr->resist_blind)
113                                 {
114                                         if (set_blind(p_ptr->blind + rand_int(200) + 200))
115                                         {
116                                                 ident = TRUE;
117                                         }
118                                 }
119                                 break;
120                         }
121
122                         case SV_FOOD_PARANOIA:
123                         {
124                                 if (!p_ptr->resist_fear)
125                                 {
126                                         if (set_afraid(p_ptr->afraid + rand_int(10) + 10))
127                                         {
128                                                 ident = TRUE;
129                                         }
130                                 }
131                                 break;
132                         }
133
134                         case SV_FOOD_CONFUSION:
135                         {
136                                 if (!p_ptr->resist_conf)
137                                 {
138                                         if (set_confused(p_ptr->confused + rand_int(10) + 10))
139                                         {
140                                                 ident = TRUE;
141                                         }
142                                 }
143                                 break;
144                         }
145
146                         case SV_FOOD_HALLUCINATION:
147                         {
148                                 if (!p_ptr->resist_chaos)
149                                 {
150                                         if (set_image(p_ptr->image + rand_int(250) + 250))
151                                         {
152                                                 ident = TRUE;
153                                         }
154                                 }
155                                 break;
156                         }
157
158                         case SV_FOOD_PARALYSIS:
159                         {
160                                 if (!p_ptr->free_act)
161                                 {
162                                         if (set_paralyzed(p_ptr->paralyzed + rand_int(10) + 10))
163                                         {
164                                                 ident = TRUE;
165                                         }
166                                 }
167                                 break;
168                         }
169
170                         case SV_FOOD_WEAKNESS:
171                         {
172 #ifdef JP
173                         take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "ÆÇÆþ¤ê¿©ÎÁ", -1);
174 #else
175                                 take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1);
176 #endif
177
178                                 (void)do_dec_stat(A_STR);
179                                 ident = TRUE;
180                                 break;
181                         }
182
183                         case SV_FOOD_SICKNESS:
184                         {
185 #ifdef JP
186                         take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "ÆÇÆþ¤ê¿©ÎÁ", -1);
187 #else
188                                 take_hit(DAMAGE_NOESCAPE, damroll(6, 6), "poisonous food", -1);
189 #endif
190
191                                 (void)do_dec_stat(A_CON);
192                                 ident = TRUE;
193                                 break;
194                         }
195
196                         case SV_FOOD_STUPIDITY:
197                         {
198 #ifdef JP
199                         take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "ÆÇÆþ¤ê¿©ÎÁ", -1);
200 #else
201                                 take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1);
202 #endif
203
204                                 (void)do_dec_stat(A_INT);
205                                 ident = TRUE;
206                                 break;
207                         }
208
209                         case SV_FOOD_NAIVETY:
210                         {
211 #ifdef JP
212                         take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "ÆÇÆþ¤ê¿©ÎÁ", -1);
213 #else
214                                 take_hit(DAMAGE_NOESCAPE, damroll(8, 8), "poisonous food", -1);
215 #endif
216
217                                 (void)do_dec_stat(A_WIS);
218                                 ident = TRUE;
219                                 break;
220                         }
221
222                         case SV_FOOD_UNHEALTH:
223                         {
224 #ifdef JP
225                         take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "ÆÇÆþ¤ê¿©ÎÁ", -1);
226 #else
227                                 take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1);
228 #endif
229
230                                 (void)do_dec_stat(A_CON);
231                                 ident = TRUE;
232                                 break;
233                         }
234
235                         case SV_FOOD_DISEASE:
236                         {
237 #ifdef JP
238                         take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "ÆÇÆþ¤ê¿©ÎÁ", -1);
239 #else
240                                 take_hit(DAMAGE_NOESCAPE, damroll(10, 10), "poisonous food", -1);
241 #endif
242
243                                 (void)do_dec_stat(A_STR);
244                                 ident = TRUE;
245                                 break;
246                         }
247
248                         case SV_FOOD_CURE_POISON:
249                         {
250                                 if (set_poisoned(0)) ident = TRUE;
251                                 break;
252                         }
253
254                         case SV_FOOD_CURE_BLINDNESS:
255                         {
256                                 if (set_blind(0)) ident = TRUE;
257                                 break;
258                         }
259
260                         case SV_FOOD_CURE_PARANOIA:
261                         {
262                                 if (set_afraid(0)) ident = TRUE;
263                                 break;
264                         }
265
266                         case SV_FOOD_CURE_CONFUSION:
267                         {
268                                 if (set_confused(0)) ident = TRUE;
269                                 break;
270                         }
271
272                         case SV_FOOD_CURE_SERIOUS:
273                         {
274                                 if (hp_player(damroll(4, 8))) ident = TRUE;
275                                 break;
276                         }
277
278                         case SV_FOOD_RESTORE_STR:
279                         {
280                                 if (do_res_stat(A_STR)) ident = TRUE;
281                                 break;
282                         }
283
284                         case SV_FOOD_RESTORE_CON:
285                         {
286                                 if (do_res_stat(A_CON)) ident = TRUE;
287                                 break;
288                         }
289
290                         case SV_FOOD_RESTORING:
291                         {
292                                 if (do_res_stat(A_STR)) ident = TRUE;
293                                 if (do_res_stat(A_INT)) ident = TRUE;
294                                 if (do_res_stat(A_WIS)) ident = TRUE;
295                                 if (do_res_stat(A_DEX)) ident = TRUE;
296                                 if (do_res_stat(A_CON)) ident = TRUE;
297                                 if (do_res_stat(A_CHR)) ident = TRUE;
298                                 break;
299                         }
300
301
302 #ifdef JP
303                 /* ¤½¤ì¤¾¤ì¤Î¿©¤Ùʪ¤Î´¶ÁÛ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¸½ */
304                 case SV_FOOD_BISCUIT:
305                 {
306                         msg_print("´Å¤¯¤Æ¥µ¥¯¥µ¥¯¤·¤Æ¤È¤Æ¤â¤ª¤¤¤·¤¤¡£");
307                         ident = TRUE;
308                         break;
309                 }
310
311                 case SV_FOOD_JERKY:
312                 {
313                         msg_print("»õ¤´¤¿¤¨¤¬¤¢¤Ã¤Æ¤ª¤¤¤·¤¤¡£");
314                         ident = TRUE;
315                         break;
316                 }
317
318                 case SV_FOOD_SLIME_MOLD:
319                 {
320                         msg_print("¤³¤ì¤Ï¤Ê¤ó¤È¤â·ÁÍƤ·¤¬¤¿¤¤Ì£¤À¡£");
321                         ident = TRUE;
322                         break;
323                 }
324
325                 case SV_FOOD_RATION:
326                 {
327                         msg_print("¤³¤ì¤Ï¤ª¤¤¤·¤¤¡£");
328                         ident = TRUE;
329                         break;
330                 }
331 #else
332                         case SV_FOOD_RATION:
333                         case SV_FOOD_BISCUIT:
334                         case SV_FOOD_JERKY:
335                         case SV_FOOD_SLIME_MOLD:
336                         {
337                                 msg_print("That tastes good.");
338                                 ident = TRUE;
339                                 break;
340                         }
341 #endif
342
343
344                         case SV_FOOD_WAYBREAD:
345                         {
346 #ifdef JP
347                         msg_print("¤³¤ì¤Ï¤Ò¤¸¤ç¤¦¤ËÈþÌ£¤À¡£");
348 #else
349                                 msg_print("That tastes good.");
350 #endif
351
352                                 (void)set_poisoned(0);
353                                 (void)hp_player(damroll(4, 8));
354                                 ident = TRUE;
355                                 break;
356                         }
357
358 #ifdef JP
359                         case SV_FOOD_PINT_OF_ALE:
360                 {
361                         msg_print("¤Î¤É¤´¤·Á֤䤫¤À¡£");
362                         ident = TRUE;
363                         break;
364                 }
365
366                         case SV_FOOD_PINT_OF_WINE:
367                         {
368                                 msg_print("That tastes good.");
369                                 ident = TRUE;
370                                 break;
371                         }
372 #else
373                         case SV_FOOD_PINT_OF_ALE:
374                         case SV_FOOD_PINT_OF_WINE:
375                         {
376                                 msg_print("That tastes good.");
377                                 ident = TRUE;
378                                 break;
379                         }
380 #endif
381
382                 }
383                 }
384                 else
385                 {
386                 }
387         }
388
389         /* Combine / Reorder the pack (later) */
390         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
391
392         if (!(object_aware_p(o_ptr)))
393         {
394                 chg_virtue(V_KNOWLEDGE, -1);
395                 chg_virtue(V_PATIENCE, -1);
396                 chg_virtue(V_CHANCE, 1);
397         }
398
399         /* We have tried it */
400         object_tried(o_ptr);
401
402         /* The player is now aware of the object */
403         if (ident && !object_aware_p(o_ptr))
404         {
405                 object_aware(o_ptr);
406                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
407         }
408
409         /* Window stuff */
410         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
411
412
413         /* Food can feed the player */
414         if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))
415         {
416                 /* Reduced nutritional benefit */
417                 (void)set_food(p_ptr->food + (o_ptr->pval / 10));
418 #ifdef JP
419 msg_print("¤¢¤Ê¤¿¤Î¤è¤¦¤Ê¼Ô¤Ë¤È¤Ã¤Æ¿©ÎȤʤɶϤ«¤Ê±ÉÍܤˤ·¤«¤Ê¤é¤Ê¤¤¡£");
420 #else
421                 msg_print("Mere victuals hold scant sustenance for a being such as yourself.");
422 #endif
423
424                 if (p_ptr->food < PY_FOOD_ALERT)   /* Hungry */
425 #ifdef JP
426 msg_print("¤¢¤Ê¤¿¤Îµ²¤¨¤Ï¿·Á¯¤Ê·ì¤Ë¤è¤Ã¤Æ¤Î¤ßËþ¤¿¤µ¤ì¤ë¡ª");
427 #else
428                         msg_print("Your hunger can only be satisfied with fresh blood!");
429 #endif
430
431         }
432         else if (p_ptr->prace == RACE_SKELETON)
433         {
434                 if (!((o_ptr->sval == SV_FOOD_WAYBREAD) ||
435                       (o_ptr->sval < SV_FOOD_BISCUIT)))
436                 {
437                         object_type forge;
438                         object_type *q_ptr = &forge;
439
440 #ifdef JP
441 msg_print("¿©¤Ùʪ¤¬¥¢¥´¤òÁÇÄ̤ꤷ¤ÆÍî¤Á¤¿¡ª");
442 #else
443                         msg_print("The food falls through your jaws!");
444 #endif
445
446
447                         /* Create the item */
448                         object_prep(q_ptr, lookup_kind(o_ptr->tval, o_ptr->sval));
449
450 #ifdef USE_SCRIPT
451                         q_ptr->python = object_create_callback(q_ptr);
452 #endif /* USE_SCRIPT */
453
454                         /* Drop the object from heaven */
455                         (void)drop_near(q_ptr, -1, py, px);
456                 }
457                 else
458                 {
459 #ifdef JP
460 msg_print("¿©¤Ùʪ¤¬¥¢¥´¤òÁÇÄ̤ꤷ¤ÆÍî¤Á¡¢¾Ã¤¨¤¿¡ª");
461 #else
462                         msg_print("The food falls through your jaws and vanishes!");
463 #endif
464
465                 }
466         }
467         else if ((p_ptr->prace == RACE_GOLEM) ||
468                  (p_ptr->prace == RACE_ZOMBIE) ||
469                  (p_ptr->prace == RACE_ENT) ||
470                  (p_ptr->prace == RACE_DEMON) ||
471                  (p_ptr->prace == RACE_ANDROID) ||
472                  (p_ptr->prace == RACE_SPECTRE) ||
473                  (mimic_info[p_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_NONLIVING))
474         {
475 #ifdef JP
476 msg_print("À¸¼Ô¤Î¿©Êª¤Ï¤¢¤Ê¤¿¤Ë¤È¤Ã¤Æ¤Û¤È¤ó¤É±ÉÍܤˤʤé¤Ê¤¤¡£");
477 #else
478                 msg_print("The food of mortals is poor sustenance for you.");
479 #endif
480
481                 set_food(p_ptr->food + ((o_ptr->pval) / 20));
482         }
483         else
484         {
485                 (void)set_food(p_ptr->food + o_ptr->pval);
486         }
487
488         /* Destroy a food in the pack */
489         if (item >= 0)
490         {
491                 inven_item_increase(item, -1);
492                 inven_item_describe(item);
493                 inven_item_optimize(item);
494         }
495
496         /* Destroy a food on the floor */
497         else
498         {
499                 floor_item_increase(0 - item, -1);
500                 floor_item_describe(0 - item);
501                 floor_item_optimize(0 - item);
502         }
503 }
504
505
506 /*
507  * Hook to determine if an object is eatable
508  */
509 static bool item_tester_hook_eatable(object_type *o_ptr)
510 {
511 //      if ((o_ptr->tval==TV_FOOD) || ((o_ptr->tval==TV_CORPSE) && o_ptr->sval)) return (TRUE);
512         if (o_ptr->tval==TV_FOOD) return (TRUE);
513
514         /* Assume not */
515         return (FALSE);
516 }
517
518
519 /*
520  * Eat some food (from the pack or floor)
521  */
522 void do_cmd_eat_food(void)
523 {
524         int         item;
525         cptr        q, s;
526
527
528         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
529         {
530                 set_action(ACTION_NONE);
531         }
532
533         /* Restrict choices to food */
534         item_tester_hook = item_tester_hook_eatable;
535
536         /* Get an item */
537 #ifdef JP
538         q = "¤É¤ì¤ò¿©¤Ù¤Þ¤¹¤«? ";
539         s = "¿©¤Ùʪ¤¬¤Ê¤¤¡£";
540 #else
541         q = "Eat which item? ";
542         s = "You have nothing to eat.";
543 #endif
544
545         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
546
547         /* Eat the object */
548         do_cmd_eat_food_aux(item);
549 }
550
551
552 /*
553  * Quaff a potion (from the pack or the floor)
554  */
555 static void do_cmd_quaff_potion_aux(int item)
556 {
557         int         ident, lev;
558         object_type     *o_ptr;
559         object_type forge;
560         object_type *q_ptr;
561
562
563         /* Take a turn */
564         energy_use = 100;
565
566         if (world_player)
567         {
568                 if (flush_failure) flush();
569 #ifdef JP
570                 msg_print("ÉÓ¤«¤é¿å¤¬Î®¤ì½Ð¤Æ¤³¤Ê¤¤¡ª");
571 #else
572                 msg_print("The potion doesn't flow out from a bottle.");
573 #endif
574
575                 sound(SOUND_FAIL);
576                 return;
577         }
578
579         if((p_ptr->pclass == CLASS_BARD) && p_ptr->magic_num1[0])
580         {
581                 stop_singing();
582         }
583
584         /* Get the item (in the pack) */
585         if (item >= 0)
586         {
587                 o_ptr = &inventory[item];
588         }
589
590         /* Get the item (on the floor) */
591         else
592         {
593                 o_ptr = &o_list[0 - item];
594         }
595
596         /* Get local object */
597         q_ptr = &forge;
598
599         /* Obtain a local object */
600         object_copy(q_ptr, o_ptr);
601
602         /* Single object */
603         q_ptr->number = 1;
604
605         /* Reduce and describe inventory */
606         if (item >= 0)
607         {
608                 inven_item_increase(item, -1);
609                 inven_item_describe(item);
610                 inven_item_optimize(item);
611         }
612
613         /* Reduce and describe floor item */
614         else
615         {
616                 floor_item_increase(0 - item, -1);
617                 floor_item_describe(0 - item);
618                 floor_item_optimize(0 - item);
619         }
620
621         /* Sound */
622         sound(SOUND_QUAFF);
623
624
625         /* Not identified yet */
626         ident = FALSE;
627
628         /* Object level */
629         lev = get_object_level(q_ptr);
630
631         /* Analyze the potion */
632         switch (q_ptr->sval)
633         {
634 #ifdef JP
635                 /* °û¤ß¤´¤¿¤¨¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¸½ */
636                 case SV_POTION_WATER:
637                 {
638                         msg_print("¸ý¤ÎÃ椬¤µ¤Ã¤Ñ¤ê¤·¤¿¡£");
639                         msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
640                         ident = TRUE;
641                         break;
642                 }
643                 case SV_POTION_APPLE_JUICE:
644                 {
645                         msg_print("´Å¤¯¤Æ¥µ¥Ã¥Ñ¥ê¤È¤·¤Æ¤¤¤Æ¡¢¤È¤Æ¤â¤ª¤¤¤·¤¤¡£");
646                         msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
647                         ident = TRUE;
648                         break;
649                 }
650                 case SV_POTION_SLIME_MOLD:
651                 {
652                         msg_print("¤Ê¤ó¤È¤âÉÔµ¤Ì£¤ÊÌ£¤À¡£");
653                         msg_print("¤Î¤É¤Î³é¤­¤¬¾¯¤·¤ª¤µ¤Þ¤Ã¤¿¡£");
654                         ident = TRUE;
655                         break;
656                 }
657 #else
658                 case SV_POTION_WATER:
659                 case SV_POTION_APPLE_JUICE:
660                 case SV_POTION_SLIME_MOLD:
661                 {
662                         msg_print("You feel less thirsty.");
663                         ident = TRUE;
664                         break;
665                 }
666 #endif
667
668
669                 case SV_POTION_SLOWNESS:
670                 {
671                         if (set_slow(randint(25) + 15, FALSE)) ident = TRUE;
672                         break;
673                 }
674
675                 case SV_POTION_SALT_WATER:
676                 {
677 #ifdef JP
678                         msg_print("¤¦¤§¡ª»×¤ï¤ºÅǤ¤¤Æ¤·¤Þ¤Ã¤¿¡£");
679 #else
680                         msg_print("The potion makes you vomit!");
681 #endif
682
683                         (void)set_food(PY_FOOD_STARVE - 1);
684                         (void)set_poisoned(0);
685                         (void)set_paralyzed(p_ptr->paralyzed + 4);
686                         ident = TRUE;
687                         break;
688                 }
689
690                 case SV_POTION_POISON:
691                 {
692                         if (!(p_ptr->resist_pois || p_ptr->oppose_pois))
693                         {
694                                 if (set_poisoned(p_ptr->poisoned + rand_int(15) + 10))
695                                 {
696                                         ident = TRUE;
697                                 }
698                         }
699                         break;
700                 }
701
702                 case SV_POTION_BLINDNESS:
703                 {
704                         if (!p_ptr->resist_blind)
705                         {
706                                 if (set_blind(p_ptr->blind + rand_int(100) + 100))
707                                 {
708                                         ident = TRUE;
709                                 }
710                         }
711                         break;
712                 }
713
714                 case SV_POTION_CONFUSION: /* Booze */
715                 {
716                         if (p_ptr->pclass != CLASS_MONK) chg_virtue(V_HARMONY, -1);
717                         else if (!p_ptr->resist_conf) p_ptr->special_attack |= ATTACK_SUIKEN;
718                         if (!p_ptr->resist_conf)
719                         {
720                                 if (set_confused(rand_int(20) + 15))
721                                 {
722                                         ident = TRUE;
723                                 }
724                         }
725
726                         if (!p_ptr->resist_chaos)
727                         {
728                                 if (one_in_(2))
729                                 {
730                                         if (set_image(p_ptr->image + rand_int(150) + 150))
731                                         {
732                                                 ident = TRUE;
733                                         }
734                                 }
735                                 if (one_in_(13) && (p_ptr->pclass != CLASS_MONK))
736                                 {
737                                         ident = TRUE;
738                                         if (one_in_(3)) lose_all_info();
739                                         else wiz_dark();
740                                         teleport_player(100);
741                                         wiz_dark();
742 #ifdef JP
743 msg_print("ÃΤé¤Ê¤¤¾ì½ê¤ÇÌܤ¬Àä᤿¡£Æ¬Äˤ¬¤¹¤ë¡£");
744 msg_print("²¿¤â»×¤¤½Ð¤»¤Ê¤¤¡£¤É¤¦¤ä¤Ã¤Æ¤³¤³¤ØÍ褿¤Î¤«¤âʬ¤«¤é¤Ê¤¤¡ª");
745 #else
746                                         msg_print("You wake up somewhere with a sore head...");
747                                         msg_print("You can't remember a thing, or how you got here!");
748 #endif
749
750                                 }
751                         }
752                         break;
753                 }
754
755                 case SV_POTION_SLEEP:
756                 {
757                         if (!p_ptr->free_act)
758                         {
759 #ifdef JP
760                 msg_print("¤¢¤Ê¤¿¤Ï̲¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
761 #else
762                 msg_print("You fall asleep.");
763 #endif
764
765
766                                 if (ironman_nightmare)
767                                 {
768 #ifdef JP
769 msg_print("¶²¤í¤·¤¤¸÷·Ê¤¬Æ¬¤ËÉ⤫¤ó¤Ç¤­¤¿¡£");
770 #else
771                                         msg_print("A horrible vision enters your mind.");
772 #endif
773
774
775                                         /* Pick a nightmare */
776                                         get_mon_num_prep(get_nightmare, NULL);
777
778                                         /* Have some nightmares */
779                                         have_nightmare(get_mon_num(MAX_DEPTH));
780
781                                         /* Remove the monster restriction */
782                                         get_mon_num_prep(NULL, NULL);
783                                 }
784                                 if (set_paralyzed(p_ptr->paralyzed + rand_int(4) + 4))
785                                 {
786                                         ident = TRUE;
787                                 }
788                         }
789                         break;
790                 }
791
792                 case SV_POTION_LOSE_MEMORIES:
793                 {
794                         if (!p_ptr->hold_life && (p_ptr->exp > 0))
795                         {
796 #ifdef JP
797                                 msg_print("²áµî¤Îµ­²±¤¬Çö¤ì¤Æ¤¤¤¯µ¤¤¬¤¹¤ë¡£");
798 #else
799                                 msg_print("You feel your memories fade.");
800 #endif
801                                 chg_virtue(V_KNOWLEDGE, -5);
802
803                                 lose_exp(p_ptr->exp / 4);
804                                 ident = TRUE;
805                         }
806                         break;
807                 }
808
809                 case SV_POTION_RUINATION:
810                 {
811 #ifdef JP
812                         msg_print("¿È¤â¿´¤â¼å¤Ã¤Æ¤­¤Æ¡¢Àºµ¤¤¬È´¤±¤Æ¤¤¤¯¤è¤¦¤À¡£");
813                         take_hit(DAMAGE_LOSELIFE, damroll(10, 10), "ÇËÌǤÎÌô", -1);
814 #else
815                         msg_print("Your nerves and muscles feel weak and lifeless!");
816                         take_hit(DAMAGE_LOSELIFE, damroll(10, 10), "a potion of Ruination", -1);
817 #endif
818
819                         (void)dec_stat(A_DEX, 25, TRUE);
820                         (void)dec_stat(A_WIS, 25, TRUE);
821                         (void)dec_stat(A_CON, 25, TRUE);
822                         (void)dec_stat(A_STR, 25, TRUE);
823                         (void)dec_stat(A_CHR, 25, TRUE);
824                         (void)dec_stat(A_INT, 25, TRUE);
825                         ident = TRUE;
826                         break;
827                 }
828
829                 case SV_POTION_DEC_STR:
830                 {
831                         if (do_dec_stat(A_STR)) ident = TRUE;
832                         break;
833                 }
834
835                 case SV_POTION_DEC_INT:
836                 {
837                         if (do_dec_stat(A_INT)) ident = TRUE;
838                         break;
839                 }
840
841                 case SV_POTION_DEC_WIS:
842                 {
843                         if (do_dec_stat(A_WIS)) ident = TRUE;
844                         break;
845                 }
846
847                 case SV_POTION_DEC_DEX:
848                 {
849                         if (do_dec_stat(A_DEX)) ident = TRUE;
850                         break;
851                 }
852
853                 case SV_POTION_DEC_CON:
854                 {
855                         if (do_dec_stat(A_CON)) ident = TRUE;
856                         break;
857                 }
858
859                 case SV_POTION_DEC_CHR:
860                 {
861                         if (do_dec_stat(A_CHR)) ident = TRUE;
862                         break;
863                 }
864
865                 case SV_POTION_DETONATIONS:
866                 {
867 #ifdef JP
868                         msg_print("ÂΤÎÃæ¤Ç·ã¤·¤¤Çúȯ¤¬µ¯¤­¤¿¡ª");
869                         take_hit(DAMAGE_NOESCAPE, damroll(50, 20), "Çúȯ¤ÎÌô", -1);
870 #else
871                         msg_print("Massive explosions rupture your body!");
872                         take_hit(DAMAGE_NOESCAPE, damroll(50, 20), "a potion of Detonation", -1);
873 #endif
874
875                         (void)set_stun(p_ptr->stun + 75);
876                         (void)set_cut(p_ptr->cut + 5000);
877                         ident = TRUE;
878                         break;
879                 }
880
881                 case SV_POTION_DEATH:
882                 {
883                         chg_virtue(V_VITALITY, -1);
884                         chg_virtue(V_UNLIFE, 5);
885 #ifdef JP
886                         msg_print("»à¤Îͽ´¶¤¬ÂÎÃæ¤ò¶î¤±¤á¤°¤Ã¤¿¡£");
887                         take_hit(DAMAGE_LOSELIFE, 5000, "»à¤ÎÌô", -1);
888 #else
889                         msg_print("A feeling of Death flows through your body.");
890                         take_hit(DAMAGE_LOSELIFE, 5000, "a potion of Death", -1);
891 #endif
892
893                         ident = TRUE;
894                         break;
895                 }
896
897                 case SV_POTION_INFRAVISION:
898                 {
899                         if (set_tim_infra(p_ptr->tim_infra + 100 + randint(100), FALSE))
900                         {
901                                 ident = TRUE;
902                         }
903                         break;
904                 }
905
906                 case SV_POTION_DETECT_INVIS:
907                 {
908                         if (set_tim_invis(p_ptr->tim_invis + 12 + randint(12), FALSE))
909                         {
910                                 ident = TRUE;
911                         }
912                         break;
913                 }
914
915                 case SV_POTION_SLOW_POISON:
916                 {
917                         if (set_poisoned(p_ptr->poisoned / 2)) ident = TRUE;
918                         break;
919                 }
920
921                 case SV_POTION_CURE_POISON:
922                 {
923                         if (set_poisoned(0)) ident = TRUE;
924                         break;
925                 }
926
927                 case SV_POTION_BOLDNESS:
928                 {
929                         if (set_afraid(0)) ident = TRUE;
930                         break;
931                 }
932
933                 case SV_POTION_SPEED:
934                 {
935                         if (!p_ptr->fast)
936                         {
937                                 if (set_fast(randint(25) + 15, FALSE)) ident = TRUE;
938                         }
939                         else
940                         {
941                                 (void)set_fast(p_ptr->fast + 5, FALSE);
942                         }
943                         break;
944                 }
945
946                 case SV_POTION_RESIST_HEAT:
947                 {
948                         if (set_oppose_fire(p_ptr->oppose_fire + randint(10) + 10, FALSE))
949                         {
950                                 ident = TRUE;
951                         }
952                         break;
953                 }
954
955                 case SV_POTION_RESIST_COLD:
956                 {
957                         if (set_oppose_cold(p_ptr->oppose_cold + randint(10) + 10, FALSE))
958                         {
959                                 ident = TRUE;
960                         }
961                         break;
962                 }
963
964                 case SV_POTION_HEROISM:
965                 {
966                         if (set_afraid(0)) ident = TRUE;
967                         if (set_hero(p_ptr->hero + randint(25) + 25, FALSE)) ident = TRUE;
968                         if (hp_player(10)) ident = TRUE;
969                         break;
970                 }
971
972                 case SV_POTION_BESERK_STRENGTH:
973                 {
974                         if (set_afraid(0)) ident = TRUE;
975                         if (set_shero(p_ptr->shero + randint(25) + 25, FALSE)) ident = TRUE;
976                         if (hp_player(30)) ident = TRUE;
977                         break;
978                 }
979
980                 case SV_POTION_CURE_LIGHT:
981                 {
982                         if (hp_player(damroll(2, 8))) ident = TRUE;
983                         if (set_blind(0)) ident = TRUE;
984                         if (set_cut(p_ptr->cut - 10)) ident = TRUE;
985                         if (set_shero(0,TRUE)) ident = TRUE;
986                         break;
987                 }
988
989                 case SV_POTION_CURE_SERIOUS:
990                 {
991                         if (hp_player(damroll(4, 8))) ident = TRUE;
992                         if (set_blind(0)) ident = TRUE;
993                         if (set_confused(0)) ident = TRUE;
994                         if (set_cut((p_ptr->cut / 2) - 50)) ident = TRUE;
995                         if (set_shero(0,TRUE)) ident = TRUE;
996                         break;
997                 }
998
999                 case SV_POTION_CURE_CRITICAL:
1000                 {
1001                         if (hp_player(damroll(6, 8))) ident = TRUE;
1002                         if (set_blind(0)) ident = TRUE;
1003                         if (set_confused(0)) ident = TRUE;
1004                         if (set_poisoned(0)) ident = TRUE;
1005                         if (set_stun(0)) ident = TRUE;
1006                         if (set_cut(0)) ident = TRUE;
1007                         if (set_shero(0,TRUE)) ident = TRUE;
1008                         break;
1009                 }
1010
1011                 case SV_POTION_HEALING:
1012                 {
1013                         if (hp_player(300)) ident = TRUE;
1014                         if (set_blind(0)) ident = TRUE;
1015                         if (set_confused(0)) ident = TRUE;
1016                         if (set_poisoned(0)) ident = TRUE;
1017                         if (set_stun(0)) ident = TRUE;
1018                         if (set_cut(0)) ident = TRUE;
1019                         if (set_shero(0,TRUE)) ident = TRUE;
1020                         break;
1021                 }
1022
1023                 case SV_POTION_STAR_HEALING:
1024                 {
1025                         if (hp_player(1200)) ident = TRUE;
1026                         if (set_blind(0)) ident = TRUE;
1027                         if (set_confused(0)) ident = TRUE;
1028                         if (set_poisoned(0)) ident = TRUE;
1029                         if (set_stun(0)) ident = TRUE;
1030                         if (set_cut(0)) ident = TRUE;
1031                         if (set_shero(0,TRUE)) ident = TRUE;
1032                         break;
1033                 }
1034
1035                 case SV_POTION_LIFE:
1036                 {
1037                         chg_virtue(V_VITALITY, 1);
1038                         chg_virtue(V_UNLIFE, -5);
1039 #ifdef JP
1040                         msg_print("ÂÎÃæ¤ËÀ¸Ì¿ÎϤ¬Ëþ¤Á¤¢¤Õ¤ì¤Æ¤­¤¿¡ª");
1041 #else
1042                         msg_print("You feel life flow through your body!");
1043 #endif
1044
1045                         restore_level();
1046                         (void)set_poisoned(0);
1047                         (void)set_blind(0);
1048                         (void)set_confused(0);
1049                         (void)set_image(0);
1050                         (void)set_stun(0);
1051                         (void)set_cut(0);
1052                         (void)do_res_stat(A_STR);
1053                         (void)do_res_stat(A_CON);
1054                         (void)do_res_stat(A_DEX);
1055                         (void)do_res_stat(A_WIS);
1056                         (void)do_res_stat(A_INT);
1057                         (void)do_res_stat(A_CHR);
1058                         (void)set_shero(0,TRUE);
1059                         hp_player(5000);
1060                         ident = TRUE;
1061                         break;
1062                 }
1063
1064                 case SV_POTION_RESTORE_MANA:
1065                 {
1066                         if (p_ptr->pclass == CLASS_MAGIC_EATER)
1067                         {
1068                                 int i;
1069                                 for (i = 0; i < 72; i++)
1070                                 {
1071                                         p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? 0x30000 : p_ptr->magic_num2[i]*0x05555;
1072                                         if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i]*0x10000) p_ptr->magic_num1[i] = p_ptr->magic_num2[i]*0x10000L;
1073                                 }
1074                                 for (; i < 108; i++)
1075                                 {
1076                                         int k_idx = lookup_kind(TV_ROD, i-72);
1077                                         p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? 0x30000 : p_ptr->magic_num2[i]*0x5555)*k_info[k_idx].pval;
1078                                         if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
1079                                 }
1080 #ifdef JP
1081                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
1082 #else
1083                                 msg_print("Your feel your head clear.");
1084 #endif
1085                                 p_ptr->window |= (PW_PLAYER);
1086                                 ident = TRUE;
1087                         }
1088                         else if (p_ptr->csp < p_ptr->msp)
1089                         {
1090                                 p_ptr->csp = p_ptr->msp;
1091                                 p_ptr->csp_frac = 0;
1092 #ifdef JP
1093                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
1094 #else
1095                                 msg_print("Your feel your head clear.");
1096 #endif
1097
1098                                 p_ptr->redraw |= (PR_MANA);
1099                                 p_ptr->window |= (PW_PLAYER);
1100                                 p_ptr->window |= (PW_SPELL);
1101                                 ident = TRUE;
1102                         }
1103                         if (set_shero(0,TRUE)) ident = TRUE;
1104                         break;
1105                 }
1106
1107                 case SV_POTION_RESTORE_EXP:
1108                 {
1109                         if (restore_level()) ident = TRUE;
1110                         break;
1111                 }
1112
1113                 case SV_POTION_RES_STR:
1114                 {
1115                         if (do_res_stat(A_STR)) ident = TRUE;
1116                         break;
1117                 }
1118
1119                 case SV_POTION_RES_INT:
1120                 {
1121                         if (do_res_stat(A_INT)) ident = TRUE;
1122                         break;
1123                 }
1124
1125                 case SV_POTION_RES_WIS:
1126                 {
1127                         if (do_res_stat(A_WIS)) ident = TRUE;
1128                         break;
1129                 }
1130
1131                 case SV_POTION_RES_DEX:
1132                 {
1133                         if (do_res_stat(A_DEX)) ident = TRUE;
1134                         break;
1135                 }
1136
1137                 case SV_POTION_RES_CON:
1138                 {
1139                         if (do_res_stat(A_CON)) ident = TRUE;
1140                         break;
1141                 }
1142
1143                 case SV_POTION_RES_CHR:
1144                 {
1145                         if (do_res_stat(A_CHR)) ident = TRUE;
1146                         break;
1147                 }
1148
1149                 case SV_POTION_INC_STR:
1150                 {
1151                         if (do_inc_stat(A_STR)) ident = TRUE;
1152                         break;
1153                 }
1154
1155                 case SV_POTION_INC_INT:
1156                 {
1157                         if (do_inc_stat(A_INT)) ident = TRUE;
1158                         break;
1159                 }
1160
1161                 case SV_POTION_INC_WIS:
1162                 {
1163                         if (do_inc_stat(A_WIS)) ident = TRUE;
1164                         break;
1165                 }
1166
1167                 case SV_POTION_INC_DEX:
1168                 {
1169                         if (do_inc_stat(A_DEX)) ident = TRUE;
1170                         break;
1171                 }
1172
1173                 case SV_POTION_INC_CON:
1174                 {
1175                         if (do_inc_stat(A_CON)) ident = TRUE;
1176                         break;
1177                 }
1178
1179                 case SV_POTION_INC_CHR:
1180                 {
1181                         if (do_inc_stat(A_CHR)) ident = TRUE;
1182                         break;
1183                 }
1184
1185                 case SV_POTION_AUGMENTATION:
1186                 {
1187                         if (do_inc_stat(A_STR)) ident = TRUE;
1188                         if (do_inc_stat(A_INT)) ident = TRUE;
1189                         if (do_inc_stat(A_WIS)) ident = TRUE;
1190                         if (do_inc_stat(A_DEX)) ident = TRUE;
1191                         if (do_inc_stat(A_CON)) ident = TRUE;
1192                         if (do_inc_stat(A_CHR)) ident = TRUE;
1193                         break;
1194                 }
1195
1196                 case SV_POTION_ENLIGHTENMENT:
1197                 {
1198                         chg_virtue(V_ENLIGHTEN, 1);
1199 #ifdef JP
1200                         msg_print("¼«Ê¬¤ÎÃÖ¤«¤ì¤Æ¤¤¤ë¾õ¶·¤¬Ç¾Î¢¤ËÉ⤫¤ó¤Ç¤­¤¿...");
1201 #else
1202                         msg_print("An image of your surroundings forms in your mind...");
1203 #endif
1204
1205                         chg_virtue(V_KNOWLEDGE, 1);
1206                         chg_virtue(V_ENLIGHTEN, 1);
1207                         wiz_lite(FALSE, FALSE);
1208                         ident = TRUE;
1209                         break;
1210                 }
1211
1212                 case SV_POTION_STAR_ENLIGHTENMENT:
1213                 {
1214 #ifdef JP
1215                         msg_print("¹¹¤Ê¤ë·¼Ìؤò´¶¤¸¤¿...");
1216 #else
1217                         msg_print("You begin to feel more enlightened...");
1218 #endif
1219
1220                         chg_virtue(V_KNOWLEDGE, 1);
1221                         chg_virtue(V_ENLIGHTEN, 1);
1222                         msg_print(NULL);
1223                         wiz_lite(TRUE, FALSE);
1224                         (void)do_inc_stat(A_INT);
1225                         (void)do_inc_stat(A_WIS);
1226                         (void)detect_traps(DETECT_RAD_DEFAULT);
1227                         (void)detect_doors(DETECT_RAD_DEFAULT);
1228                         (void)detect_stairs(DETECT_RAD_DEFAULT);
1229                         (void)detect_treasure(DETECT_RAD_DEFAULT);
1230                         (void)detect_objects_gold(DETECT_RAD_DEFAULT);
1231                         (void)detect_objects_normal(DETECT_RAD_DEFAULT);
1232                         identify_pack();
1233                         self_knowledge();
1234                         ident = TRUE;
1235                         break;
1236                 }
1237
1238                 case SV_POTION_SELF_KNOWLEDGE:
1239                 {
1240 #ifdef JP
1241                         msg_print("¼«Ê¬¼«¿È¤Î¤³¤È¤¬¾¯¤·¤Ïʬ¤«¤Ã¤¿µ¤¤¬¤¹¤ë...");
1242 #else
1243                         msg_print("You begin to know yourself a little better...");
1244 #endif
1245
1246                         msg_print(NULL);
1247                         self_knowledge();
1248                         ident = TRUE;
1249                         break;
1250                 }
1251
1252                 case SV_POTION_EXPERIENCE:
1253                 {
1254                         if (p_ptr->prace == RACE_ANDROID) break;
1255                         chg_virtue(V_ENLIGHTEN, 1);
1256                         if (p_ptr->exp < PY_MAX_EXP)
1257                         {
1258                                 s32b ee = (p_ptr->exp / 2) + 10;
1259                                 if (ee > 100000L) ee = 100000L;
1260 #ifdef JP
1261                                 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1262 #else
1263                                 msg_print("You feel more experienced.");
1264 #endif
1265
1266                                 gain_exp(ee);
1267                                 ident = TRUE;
1268                         }
1269                         break;
1270                 }
1271
1272                 case SV_POTION_RESISTANCE:
1273                 {
1274                         (void)set_oppose_acid(p_ptr->oppose_acid + randint(20) + 20, FALSE);
1275                         (void)set_oppose_elec(p_ptr->oppose_elec + randint(20) + 20, FALSE);
1276                         (void)set_oppose_fire(p_ptr->oppose_fire + randint(20) + 20, FALSE);
1277                         (void)set_oppose_cold(p_ptr->oppose_cold + randint(20) + 20, FALSE);
1278                         (void)set_oppose_pois(p_ptr->oppose_pois + randint(20) + 20, FALSE);
1279                         ident = TRUE;
1280                         break;
1281                 }
1282
1283                 case SV_POTION_CURING:
1284                 {
1285                         if (hp_player(50)) ident = TRUE;
1286                         if (set_blind(0)) ident = TRUE;
1287                         if (set_poisoned(0)) ident = TRUE;
1288                         if (set_confused(0)) ident = TRUE;
1289                         if (set_stun(0)) ident = TRUE;
1290                         if (set_cut(0)) ident = TRUE;
1291                         if (set_image(0)) ident = TRUE;
1292                         break;
1293                 }
1294
1295                 case SV_POTION_INVULNERABILITY:
1296                 {
1297                         (void)set_invuln(p_ptr->invuln + randint(4) + 4, FALSE);
1298                         ident = TRUE;
1299                         break;
1300                 }
1301
1302                 case SV_POTION_NEW_LIFE:
1303                 {
1304                         do_cmd_rerate(FALSE);
1305                         get_max_stats();
1306                         p_ptr->update |= PU_BONUS;
1307                         if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
1308                         {
1309                                 chg_virtue(V_CHANCE, -5);
1310 #ifdef JP
1311 msg_print("Á´¤Æ¤ÎÆÍÁ³ÊÑ°Û¤¬¼£¤Ã¤¿¡£");
1312 #else
1313                                 msg_print("You are cured of all mutations.");
1314 #endif
1315
1316                                 p_ptr->muta1 = p_ptr->muta2 = p_ptr->muta3 = 0;
1317                                 p_ptr->update |= PU_BONUS;
1318                                 handle_stuff();
1319                                 mutant_regenerate_mod = calc_mutant_regenerate_mod();
1320                         }
1321                         ident = TRUE;
1322                         break;
1323                 }
1324
1325                 case SV_POTION_NEO_TSUYOSHI:
1326                 {
1327                         (void)set_image(0);
1328                         (void)set_tsuyoshi(p_ptr->tsuyoshi + randint(100) + 100, FALSE);
1329                         ident = TRUE;
1330                         break;
1331                 }
1332
1333                 case SV_POTION_TSUYOSHI:
1334                 {
1335 #ifdef JP
1336 msg_print("¡Ö¥ª¥¯¥ì·»¤µ¤ó¡ª¡×");
1337 #else
1338                         msg_print("Brother OKURE!");
1339 #endif
1340                         msg_print(NULL);
1341                         p_ptr->tsuyoshi = 1;
1342                         (void)set_tsuyoshi(0, TRUE);
1343                         if (!p_ptr->resist_chaos)
1344                         {
1345                                 (void)set_image(50 + randint(50));
1346                         }
1347                         ident = TRUE;
1348                         break;
1349                 }
1350                 
1351                 case SV_POTION_POLYMORPH:
1352                 {
1353                         if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && one_in_(23))
1354                         {
1355                                 chg_virtue(V_CHANCE, -5);
1356 #ifdef JP
1357 msg_print("Á´¤Æ¤ÎÆÍÁ³ÊÑ°Û¤¬¼£¤Ã¤¿¡£");
1358 #else
1359                                 msg_print("You are cured of all mutations.");
1360 #endif
1361
1362                                 p_ptr->muta1 = p_ptr->muta2 = p_ptr->muta3 = 0;
1363                                 p_ptr->update |= PU_BONUS;
1364                                 handle_stuff();
1365                         }
1366                         else
1367                         {
1368                                 do
1369                                 {
1370                                         if (one_in_(2))
1371                                         {
1372                                                 if(gain_random_mutation(0)) ident = TRUE;
1373                                         }
1374                                         else if (lose_mutation(0)) ident = TRUE;
1375                                 } while(!ident || one_in_(2));
1376                         }
1377                         break;
1378                 }
1379         }
1380
1381         if (p_ptr->prace == RACE_SKELETON)
1382         {
1383 #ifdef JP
1384 msg_print("±ÕÂΤΰìÉô¤Ï¤¢¤Ê¤¿¤Î¥¢¥´¤òÁÇÄ̤ꤷ¤ÆÍî¤Á¤¿¡ª");
1385 #else
1386                 msg_print("Some of the fluid falls through your jaws!");
1387 #endif
1388
1389                 (void)potion_smash_effect(0, py, px, q_ptr->k_idx);
1390         }
1391
1392         /* Combine / Reorder the pack (later) */
1393         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1394
1395         if (!(object_aware_p(o_ptr)))
1396         {
1397                 chg_virtue(V_PATIENCE, -1);
1398                 chg_virtue(V_CHANCE, 1);
1399                 chg_virtue(V_KNOWLEDGE, -1);
1400         }
1401
1402         /* The item has been tried */
1403         object_tried(q_ptr);
1404
1405         /* An identification was made */
1406         if (ident && !object_aware_p(q_ptr))
1407         {
1408                 object_aware(q_ptr);
1409                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
1410         }
1411
1412         /* Window stuff */
1413         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
1414
1415         /* Potions can feed the player */
1416         switch (p_ptr->mimic_form)
1417         {
1418         case MIMIC_NONE:
1419                 switch (p_ptr->prace)
1420                 {
1421                         case RACE_VAMPIRE:
1422                                 (void)set_food(p_ptr->food + (o_ptr->pval / 10));
1423                                 break;
1424                         case RACE_SKELETON:
1425                                 /* Do nothing */
1426                                 break;
1427                         case RACE_GOLEM:
1428                         case RACE_ZOMBIE:
1429                         case RACE_ENT:
1430                         case RACE_DEMON:
1431                         case RACE_SPECTRE:
1432                         case RACE_ANDROID:
1433                                 set_food(p_ptr->food + ((o_ptr->pval) / 20));
1434                                 break;
1435                         default:
1436                                 (void)set_food(p_ptr->food + o_ptr->pval);
1437                                 break;
1438                 }
1439                 break;
1440         case MIMIC_DEMON:
1441         case MIMIC_DEMON_LORD:
1442                 set_food(p_ptr->food + ((o_ptr->pval) / 20));
1443                 break;
1444         case MIMIC_VAMPIRE:
1445                 (void)set_food(p_ptr->food + (o_ptr->pval / 10));
1446                 break;
1447         default:
1448                 (void)set_food(p_ptr->food + o_ptr->pval);
1449                 break;
1450         }
1451 }
1452
1453
1454 void do_cmd_quaff_potion(void)
1455 {
1456         int  item;
1457         cptr q, s;
1458
1459         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1460         {
1461                 set_action(ACTION_NONE);
1462         }
1463
1464         /* Restrict choices to potions */
1465         item_tester_tval = TV_POTION;
1466
1467         /* Get an item */
1468 #ifdef JP
1469         q = "¤É¤ÎÌô¤ò°û¤ß¤Þ¤¹¤«? ";
1470         s = "°û¤á¤ëÌô¤¬¤Ê¤¤¡£";
1471 #else
1472         q = "Quaff which potion? ";
1473         s = "You have no potions to quaff.";
1474 #endif
1475
1476         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1477
1478         /* Quaff the potion */
1479         do_cmd_quaff_potion_aux(item);
1480 }
1481
1482
1483 /*
1484  * Read a scroll (from the pack or floor).
1485  *
1486  * Certain scrolls can be "aborted" without losing the scroll.  These
1487  * include scrolls with no effects but recharge or identify, which are
1488  * cancelled before use.  XXX Reading them still takes a turn, though.
1489  */
1490 static void do_cmd_read_scroll_aux(int item)
1491 {
1492         int         k, used_up, ident, lev;
1493         object_type *o_ptr;
1494         char        Rumor[1024];
1495
1496
1497         /* Get the item (in the pack) */
1498         if (item >= 0)
1499         {
1500                 o_ptr = &inventory[item];
1501         }
1502
1503         /* Get the item (on the floor) */
1504         else
1505         {
1506                 o_ptr = &o_list[0 - item];
1507         }
1508
1509
1510         /* Take a turn */
1511         energy_use = 100;
1512
1513         if (world_player)
1514         {
1515                 if (flush_failure) flush();
1516 #ifdef JP
1517                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
1518 #else
1519                 msg_print("Nothing happen.");
1520 #endif
1521
1522                 sound(SOUND_FAIL);
1523                 return;
1524         }
1525
1526         if (p_ptr->pclass == CLASS_BERSERKER)
1527         {
1528 #ifdef JP
1529                 msg_print("´¬Êª¤Ê¤ó¤ÆÆɤá¤Ê¤¤¡£");
1530 #else
1531                 msg_print("You cannot read.");
1532 #endif
1533                 return;
1534         }
1535
1536         if((p_ptr->pclass == CLASS_BARD) && p_ptr->magic_num1[0])
1537         {
1538                 stop_singing();
1539         }
1540
1541         /* Not identified yet */
1542         ident = FALSE;
1543
1544         /* Object level */
1545         lev = get_object_level(o_ptr);
1546
1547         /* Assume the scroll will get used up */
1548         used_up = TRUE;
1549
1550         if (o_ptr->tval == TV_SCROLL)
1551         {
1552         /* Analyze the scroll */
1553         switch (o_ptr->sval)
1554         {
1555                 case SV_SCROLL_DARKNESS:
1556                 {
1557                         if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
1558                         {
1559                                 (void)set_blind(p_ptr->blind + 3 + randint(5));
1560                         }
1561                         if (unlite_area(10, 3)) ident = TRUE;
1562                         break;
1563                 }
1564
1565                 case SV_SCROLL_AGGRAVATE_MONSTER:
1566                 {
1567 #ifdef JP
1568                         msg_print("¥«¥ó¹â¤¯¤¦¤Ê¤ëÍͤʲ»¤¬ÊÕ¤ê¤òʤ¤Ã¤¿¡£");
1569 #else
1570                         msg_print("There is a high pitched humming noise.");
1571 #endif
1572
1573                         aggravate_monsters(0);
1574                         ident = TRUE;
1575                         break;
1576                 }
1577
1578                 case SV_SCROLL_CURSE_ARMOR:
1579                 {
1580                         if (curse_armor()) ident = TRUE;
1581                         break;
1582                 }
1583
1584                 case SV_SCROLL_CURSE_WEAPON:
1585                 {
1586                         if (curse_weapon(FALSE, INVEN_RARM)) ident = TRUE;
1587                         break;
1588                 }
1589
1590                 case SV_SCROLL_SUMMON_MONSTER:
1591                 {
1592                         for (k = 0; k < randint(3); k++)
1593                         {
1594                                 if (summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, TRUE))
1595                                 {
1596                                         ident = TRUE;
1597                                 }
1598                         }
1599                         break;
1600                 }
1601
1602                 case SV_SCROLL_SUMMON_UNDEAD:
1603                 {
1604                         for (k = 0; k < randint(3); k++)
1605                         {
1606                                 if (summon_specific(0, py, px, dun_level, SUMMON_UNDEAD, TRUE, FALSE, FALSE, TRUE, TRUE))
1607                                 {
1608                                         ident = TRUE;
1609                                 }
1610                         }
1611                         break;
1612                 }
1613
1614                 case SV_SCROLL_SUMMON_PET:
1615                 {
1616                         if (summon_specific(-1, py, px, dun_level, 0, TRUE, TRUE, TRUE, FALSE, FALSE))
1617                         {
1618                                 ident = TRUE;
1619                         }
1620                         break;
1621                 }
1622
1623                 case SV_SCROLL_SUMMON_KIN:
1624                 {
1625                         if (summon_kin_player(TRUE, p_ptr->lev, py, px, TRUE))
1626                         {
1627                                 ident = TRUE;
1628                         }
1629                         break;
1630                 }
1631
1632                 case SV_SCROLL_TRAP_CREATION:
1633                 {
1634                         if (trap_creation(py, px)) ident = TRUE;
1635                         break;
1636                 }
1637
1638                 case SV_SCROLL_PHASE_DOOR:
1639                 {
1640                         teleport_player(10);
1641                         ident = TRUE;
1642                         break;
1643                 }
1644
1645                 case SV_SCROLL_TELEPORT:
1646                 {
1647                         teleport_player(100);
1648                         ident = TRUE;
1649                         break;
1650                 }
1651
1652                 case SV_SCROLL_TELEPORT_LEVEL:
1653                 {
1654                         (void)teleport_player_level();
1655                         ident = TRUE;
1656                         break;
1657                 }
1658
1659                 case SV_SCROLL_WORD_OF_RECALL:
1660                 {
1661                         if (!word_of_recall()) used_up = FALSE;
1662                         ident = TRUE;
1663                         break;
1664                 }
1665
1666                 case SV_SCROLL_IDENTIFY:
1667                 {
1668                         ident = TRUE;
1669                         if (!ident_spell(FALSE)) used_up = FALSE;
1670                         break;
1671                 }
1672
1673                 case SV_SCROLL_STAR_IDENTIFY:
1674                 {
1675                         ident = TRUE;
1676                         if (!identify_fully(FALSE)) used_up = FALSE;
1677                         break;
1678                 }
1679
1680                 case SV_SCROLL_REMOVE_CURSE:
1681                 {
1682                         if (remove_curse())
1683                         {
1684 #ifdef JP
1685                                 msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1686 #else
1687                                 msg_print("You feel as if someone is watching over you.");
1688 #endif
1689
1690                                 ident = TRUE;
1691                         }
1692                         break;
1693                 }
1694
1695                 case SV_SCROLL_STAR_REMOVE_CURSE:
1696                 {
1697                         if (remove_all_curse())
1698                         {
1699 #ifdef JP
1700                                 msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1701 #else
1702                                 msg_print("You feel as if someone is watching over you.");
1703 #endif
1704                         }
1705                         ident = TRUE;
1706                         break;
1707                 }
1708
1709                 case SV_SCROLL_ENCHANT_ARMOR:
1710                 {
1711                         ident = TRUE;
1712                         if (!enchant_spell(0, 0, 1)) used_up = FALSE;
1713                         break;
1714                 }
1715
1716                 case SV_SCROLL_ENCHANT_WEAPON_TO_HIT:
1717                 {
1718                         if (!enchant_spell(1, 0, 0)) used_up = FALSE;
1719                         ident = TRUE;
1720                         break;
1721                 }
1722
1723                 case SV_SCROLL_ENCHANT_WEAPON_TO_DAM:
1724                 {
1725                         if (!enchant_spell(0, 1, 0)) used_up = FALSE;
1726                         ident = TRUE;
1727                         break;
1728                 }
1729
1730                 case SV_SCROLL_STAR_ENCHANT_ARMOR:
1731                 {
1732                         if (!enchant_spell(0, 0, randint(3) + 2)) used_up = FALSE;
1733                         ident = TRUE;
1734                         break;
1735                 }
1736
1737                 case SV_SCROLL_STAR_ENCHANT_WEAPON:
1738                 {
1739                         if (!enchant_spell(randint(3), randint(3), 0)) used_up = FALSE;
1740                         ident = TRUE;
1741                         break;
1742                 }
1743
1744                 case SV_SCROLL_RECHARGING:
1745                 {
1746                         if (!recharge(130)) used_up = FALSE;
1747                         ident = TRUE;
1748                         break;
1749                 }
1750
1751                 case SV_SCROLL_MUNDANITY:
1752                 {
1753                         ident = TRUE;
1754                         if (!mundane_spell(FALSE)) used_up = FALSE;
1755                         break;
1756                 }
1757
1758                 case SV_SCROLL_LIGHT:
1759                 {
1760                         if (lite_area(damroll(2, 8), 2)) ident = TRUE;
1761                         break;
1762                 }
1763
1764                 case SV_SCROLL_MAPPING:
1765                 {
1766                         map_area(DETECT_RAD_MAP);
1767                         ident = TRUE;
1768                         break;
1769                 }
1770
1771                 case SV_SCROLL_DETECT_GOLD:
1772                 {
1773                         if (detect_treasure(DETECT_RAD_DEFAULT)) ident = TRUE;
1774                         if (detect_objects_gold(DETECT_RAD_DEFAULT)) ident = TRUE;
1775                         break;
1776                 }
1777
1778                 case SV_SCROLL_DETECT_ITEM:
1779                 {
1780                         if (detect_objects_normal(DETECT_RAD_DEFAULT)) ident = TRUE;
1781                         break;
1782                 }
1783
1784                 case SV_SCROLL_DETECT_TRAP:
1785                 {
1786                         if (detect_traps(DETECT_RAD_DEFAULT)) ident = TRUE;
1787                         break;
1788                 }
1789
1790                 case SV_SCROLL_DETECT_DOOR:
1791                 {
1792                         if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
1793                         if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
1794                         break;
1795                 }
1796
1797                 case SV_SCROLL_DETECT_INVIS:
1798                 {
1799                         if (detect_monsters_invis(DETECT_RAD_DEFAULT)) ident = TRUE;
1800                         break;
1801                 }
1802
1803                 case SV_SCROLL_SATISFY_HUNGER:
1804                 {
1805                         if (set_food(PY_FOOD_MAX - 1)) ident = TRUE;
1806                         break;
1807                 }
1808
1809                 case SV_SCROLL_BLESSING:
1810                 {
1811                         if (set_blessed(p_ptr->blessed + randint(12) + 6, FALSE)) ident = TRUE;
1812                         break;
1813                 }
1814
1815                 case SV_SCROLL_HOLY_CHANT:
1816                 {
1817                         if (set_blessed(p_ptr->blessed + randint(24) + 12, FALSE)) ident = TRUE;
1818                         break;
1819                 }
1820
1821                 case SV_SCROLL_HOLY_PRAYER:
1822                 {
1823                         if (set_blessed(p_ptr->blessed + randint(48) + 24, FALSE)) ident = TRUE;
1824                         break;
1825                 }
1826
1827                 case SV_SCROLL_MONSTER_CONFUSION:
1828                 {
1829                         if (!(p_ptr->special_attack & ATTACK_CONFUSE))
1830                         {
1831 #ifdef JP
1832                                 msg_print("¼ê¤¬µ±¤­»Ï¤á¤¿¡£");
1833 #else
1834                                 msg_print("Your hands begin to glow.");
1835 #endif
1836
1837                                 p_ptr->special_attack |= ATTACK_CONFUSE;
1838                                 p_ptr->redraw |= (PR_STATUS);
1839                                 ident = TRUE;
1840                         }
1841                         break;
1842                 }
1843
1844                 case SV_SCROLL_PROTECTION_FROM_EVIL:
1845                 {
1846                         k = 3 * p_ptr->lev;
1847                         if (set_protevil(p_ptr->protevil + randint(25) + k, FALSE)) ident = TRUE;
1848                         break;
1849                 }
1850
1851                 case SV_SCROLL_RUNE_OF_PROTECTION:
1852                 {
1853                         warding_glyph();
1854                         ident = TRUE;
1855                         break;
1856                 }
1857
1858                 case SV_SCROLL_TRAP_DOOR_DESTRUCTION:
1859                 {
1860                         if (destroy_doors_touch()) ident = TRUE;
1861                         break;
1862                 }
1863
1864                 case SV_SCROLL_STAR_DESTRUCTION:
1865                 {
1866                         if (destroy_area(py, px, 13+rand_int(5), TRUE))
1867                                 ident = TRUE;
1868                         else
1869 #ifdef JP
1870 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Íɤ줿...");
1871 #else
1872                                 msg_print("The dungeon trembles...");
1873 #endif
1874
1875
1876                         break;
1877                 }
1878
1879                 case SV_SCROLL_DISPEL_UNDEAD:
1880                 {
1881                         if (dispel_undead(80)) ident = TRUE;
1882                         break;
1883                 }
1884
1885                 case SV_SCROLL_SPELL:
1886                 {
1887                         if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_IMITATOR) || (p_ptr->pclass == CLASS_MINDCRAFTER) || (p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_ARCHER) || (p_ptr->pclass == CLASS_MAGIC_EATER) || (p_ptr->pclass == CLASS_RED_MAGE) || (p_ptr->pclass == CLASS_SAMURAI) || (p_ptr->pclass == CLASS_BLUE_MAGE) || (p_ptr->pclass == CLASS_CAVALRY) || (p_ptr->pclass == CLASS_BERSERKER) || (p_ptr->pclass == CLASS_SMITH) || (p_ptr->pclass == CLASS_MIRROR_MASTER)) break;
1888                         p_ptr->add_spells++;
1889                         p_ptr->update |= (PU_SPELLS);
1890                         ident = TRUE;
1891                         break;
1892                 }
1893
1894                 case SV_SCROLL_GENOCIDE:
1895                 {
1896                         (void)symbol_genocide(300, TRUE);
1897                         ident = TRUE;
1898                         break;
1899                 }
1900
1901                 case SV_SCROLL_MASS_GENOCIDE:
1902                 {
1903                         (void)mass_genocide(300, TRUE);
1904                         ident = TRUE;
1905                         break;
1906                 }
1907
1908                 case SV_SCROLL_ACQUIREMENT:
1909                 {
1910                         acquirement(py, px, 1, TRUE, FALSE);
1911                         ident = TRUE;
1912                         break;
1913                 }
1914
1915                 case SV_SCROLL_STAR_ACQUIREMENT:
1916                 {
1917                         acquirement(py, px, randint(2) + 1, TRUE, FALSE);
1918                         ident = TRUE;
1919                         break;
1920                 }
1921
1922                 /* New Hengband scrolls */
1923                 case SV_SCROLL_FIRE:
1924                 {
1925                         fire_ball(GF_FIRE, 0, 666, 4);
1926                         /* Note: "Double" damage since it is centered on the player ... */
1927                         if (!(p_ptr->oppose_fire || p_ptr->resist_fire || p_ptr->immune_fire))
1928 #ifdef JP
1929 take_hit(DAMAGE_NOESCAPE, 50+randint(50), "±ê¤Î´¬Êª", -1);
1930 #else
1931                                 take_hit(DAMAGE_NOESCAPE, 50 + randint(50), "a Scroll of Fire", -1);
1932 #endif
1933
1934                         ident = TRUE;
1935                         break;
1936                 }
1937
1938
1939                 case SV_SCROLL_ICE:
1940                 {
1941                         fire_ball(GF_ICE, 0, 777, 4);
1942                         if (!(p_ptr->oppose_cold || p_ptr->resist_cold || p_ptr->immune_cold))
1943 #ifdef JP
1944 take_hit(DAMAGE_NOESCAPE, 100+randint(100), "ɹ¤Î´¬Êª", -1);
1945 #else
1946                                 take_hit(DAMAGE_NOESCAPE, 100 + randint(100), "a Scroll of Ice", -1);
1947 #endif
1948
1949                         ident = TRUE;
1950                         break;
1951                 }
1952
1953                 case SV_SCROLL_CHAOS:
1954                 {
1955                         fire_ball(GF_CHAOS, 0, 1000, 4);
1956                         if (!p_ptr->resist_chaos)
1957 #ifdef JP
1958 take_hit(DAMAGE_NOESCAPE, 111+randint(111), "¥í¥°¥ë¥¹¤Î´¬Êª", -1);
1959 #else
1960                                 take_hit(DAMAGE_NOESCAPE, 111 + randint(111), "a Scroll of Logrus", -1);
1961 #endif
1962
1963                         ident = TRUE;
1964                         break;
1965                 }
1966
1967                 case SV_SCROLL_RUMOR:
1968                 {
1969                         errr err = 0;
1970
1971                         switch (randint(20))
1972                         {
1973                                 case 1:
1974 #ifdef JP
1975 err = get_rnd_line("chainswd_j.txt", 0, Rumor);
1976 #else
1977                                         err = get_rnd_line("chainswd.txt", 0, Rumor);
1978 #endif
1979
1980                                         break;
1981                                 case 2:
1982 #ifdef JP
1983 err = get_rnd_line("error_j.txt", 0, Rumor);
1984 #else
1985                                         err = get_rnd_line("error.txt", 0, Rumor);
1986 #endif
1987
1988                                         break;
1989                                 case 3:
1990                                 case 4:
1991                                 case 5:
1992 #ifdef JP
1993 err = get_rnd_line("death_j.txt", 0, Rumor);
1994 #else
1995                                         err = get_rnd_line("death.txt", 0, Rumor);
1996 #endif
1997
1998                                         break;
1999                                 default:
2000 #ifdef JP
2001 err = get_rnd_line_jonly("rumors_j.txt", 0, Rumor, 10);
2002 #else
2003                                         err = get_rnd_line("rumors.txt", 0, Rumor);
2004 #endif
2005
2006                                         break;
2007                         }
2008
2009                         /* An error occured */
2010 #ifdef JP
2011 if (err) strcpy(Rumor, "±³¤Î±½¤â¤¢¤ë¡£");
2012 #else
2013                         if (err) strcpy(Rumor, "Some rumors are wrong.");
2014 #endif
2015
2016
2017 #ifdef JP
2018 msg_print("´¬Êª¤Ë¤Ï¥á¥Ã¥»¡¼¥¸¤¬½ñ¤«¤ì¤Æ¤¤¤ë:");
2019 #else
2020                         msg_print("There is message on the scroll. It says:");
2021 #endif
2022
2023                         msg_print(NULL);
2024                         msg_format("%s", Rumor);
2025                         msg_print(NULL);
2026 #ifdef JP
2027 msg_print("´¬Êª¤Ï±ì¤òΩ¤Æ¤Æ¾Ã¤¨µî¤Ã¤¿¡ª");
2028 #else
2029                         msg_print("The scroll disappears in a puff of smoke!");
2030 #endif
2031
2032                         ident = TRUE;
2033                         break;
2034                 }
2035
2036                 case SV_SCROLL_ARTIFACT:
2037                 {
2038                         ident = TRUE;
2039                         if (!artifact_scroll()) used_up = FALSE;
2040                         break;
2041                 }
2042
2043                 case SV_SCROLL_RESET_RECALL:
2044                 {
2045                         ident = TRUE;
2046                         if (!reset_recall()) used_up = FALSE;
2047                         break;
2048                 }
2049         }
2050         }
2051         else if (o_ptr->tval == TV_SOFT_ARMOR)
2052         {
2053 #ifdef JP
2054                 msg_print("»ä¤Ï¶ìÏ«¤·¤Æ¡Ø¥°¥ì¡¼¥¿¡¼¡¦¥Ø¥ë=¥Ó¡¼¥¹¥È¡Ù¤òÅݤ·¤¿¡£");
2055                 msg_print("¤·¤«¤·¼ê¤ËÆþ¤Ã¤¿¤Î¤Ï¤³¤Î¤­¤¿¤Ê¤¤£Ô¥·¥ã¥Ä¤À¤±¤À¤Ã¤¿¡£");
2056 #else
2057                 msg_print("I had a very hard time to kill the Greater hell-beast, ");
2058                 msg_print("but all I got was this lousy t-shirt!");
2059 #endif
2060                 used_up = FALSE;
2061         }
2062         else if (o_ptr->name1 == ART_POWER)
2063         {
2064 #ifdef JP
2065                 msg_print("¡Ö°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤òÅý¤Ù¡¢");
2066                 msg_print(NULL);
2067                 msg_print("°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤ò¸«¤Ä¤±¡¢");
2068                 msg_print(NULL);
2069                 msg_print("°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤òÊá¤é¤¨¤Æ");
2070                 msg_print(NULL);
2071                 msg_print("°Å°Ç¤ÎÃæ¤Ë·Ò¤®¤È¤á¤ë¡£¡×");
2072 #else
2073                 msg_print("'One Ring to rule them all, ");
2074                 msg_print(NULL);
2075                 msg_print("One Ring to find them, ");
2076                 msg_print(NULL);
2077                 msg_print("One Ring to bring them all ");
2078                 msg_print(NULL);
2079                 msg_print("and in the darkness bind them.'");
2080 #endif
2081                 used_up = FALSE;
2082         }
2083         else
2084         {
2085                 cptr q;
2086                 char o_name[MAX_NLEN];
2087                 char buf[1024];
2088
2089                 /* Save screen */
2090                 screen_save();
2091
2092                 q=format("book-%d_jp.txt",o_ptr->sval);
2093
2094                 /* Display object description */
2095                 object_desc(o_name, o_ptr, TRUE, 0);
2096
2097                 /* Build the filename */
2098                 path_build(buf, 1024, ANGBAND_DIR_FILE, q);
2099
2100                 /* Peruse the help file */
2101                 (void)show_file(TRUE, buf, o_name, 0, 0);
2102
2103                 /* Load screen */
2104                 screen_load();
2105
2106                 used_up=FALSE;
2107         }
2108
2109
2110         /* Combine / Reorder the pack (later) */
2111         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2112
2113         if (!(object_aware_p(o_ptr)))
2114         {
2115                 chg_virtue(V_PATIENCE, -1);
2116                 chg_virtue(V_CHANCE, 1);
2117                 chg_virtue(V_KNOWLEDGE, -1);
2118         }
2119
2120         /* The item was tried */
2121         object_tried(o_ptr);
2122
2123         /* An identification was made */
2124         if (ident && !object_aware_p(o_ptr))
2125         {
2126                 object_aware(o_ptr);
2127                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
2128         }
2129
2130         /* Window stuff */
2131         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2132
2133
2134         /* Hack -- allow certain scrolls to be "preserved" */
2135         if (!used_up)
2136         {
2137                 return;
2138         }
2139
2140         sound(SOUND_SCROLL);
2141
2142         /* Destroy a scroll in the pack */
2143         if (item >= 0)
2144         {
2145                 inven_item_increase(item, -1);
2146                 inven_item_describe(item);
2147                 inven_item_optimize(item);
2148         }
2149
2150         /* Destroy a scroll on the floor */
2151         else
2152         {
2153                 floor_item_increase(0 - item, -1);
2154                 floor_item_describe(0 - item);
2155                 floor_item_optimize(0 - item);
2156         }
2157
2158         /* Can save again */
2159 }
2160
2161
2162 /*
2163  * Hook to determine if an object is readable
2164  */
2165 static bool item_tester_hook_readable(object_type *o_ptr)
2166 {
2167         if ((o_ptr->tval==TV_SCROLL) || (o_ptr->tval==TV_PARCHEMENT) || ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_T_SHIRT)) || (o_ptr->name1 == ART_POWER)) return (TRUE);
2168
2169         /* Assume not */
2170         return (FALSE);
2171 }
2172
2173
2174 void do_cmd_read_scroll(void)
2175 {
2176         int  item;
2177         cptr q, s;
2178
2179         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
2180         {
2181                 set_action(ACTION_NONE);
2182         }
2183
2184         /* Check some conditions */
2185         if (p_ptr->blind)
2186         {
2187 #ifdef JP
2188                 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡£");
2189 #else
2190                 msg_print("You can't see anything.");
2191 #endif
2192
2193                 return;
2194         }
2195         if (no_lite())
2196         {
2197 #ifdef JP
2198                 msg_print("ÌÀ¤«¤ê¤¬¤Ê¤¤¤Î¤Ç¡¢°Å¤¯¤ÆÆɤá¤Ê¤¤¡£");
2199 #else
2200                 msg_print("You have no light to read by.");
2201 #endif
2202
2203                 return;
2204         }
2205         if (p_ptr->confused)
2206         {
2207 #ifdef JP
2208                 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡£");
2209 #else
2210                 msg_print("You are too confused!");
2211 #endif
2212
2213                 return;
2214         }
2215
2216
2217         /* Restrict choices to scrolls */
2218         item_tester_hook = item_tester_hook_readable;
2219
2220         /* Get an item */
2221 #ifdef JP
2222         q = "¤É¤Î´¬Êª¤òÆɤߤޤ¹¤«? ";
2223         s = "Æɤá¤ë´¬Êª¤¬¤Ê¤¤¡£";
2224 #else
2225         q = "Read which scroll? ";
2226         s = "You have no scrolls to read.";
2227 #endif
2228
2229         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
2230
2231         /* Read the scroll */
2232         do_cmd_read_scroll_aux(item);
2233 }
2234
2235
2236 static int staff_effect(int sval, bool *use_charge, bool magic)
2237 {
2238         int k;
2239         int ident = FALSE;
2240
2241         /* Analyze the staff */
2242         switch (sval)
2243         {
2244                 case SV_STAFF_DARKNESS:
2245                 {
2246                         if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
2247                         {
2248                                 if (set_blind(p_ptr->blind + 3 + randint(5))) ident = TRUE;
2249                         }
2250                         if (unlite_area(10, 3)) ident = TRUE;
2251                         break;
2252                 }
2253
2254                 case SV_STAFF_SLOWNESS:
2255                 {
2256                         if (set_slow(p_ptr->slow + randint(30) + 15, FALSE)) ident = TRUE;
2257                         break;
2258                 }
2259
2260                 case SV_STAFF_HASTE_MONSTERS:
2261                 {
2262                         if (speed_monsters()) ident = TRUE;
2263                         break;
2264                 }
2265
2266                 case SV_STAFF_SUMMONING:
2267                 {
2268                         for (k = 0; k < randint(4); k++)
2269                         {
2270                                 if (summon_specific(0, py, px, dun_level, 0, TRUE, FALSE, FALSE, TRUE, TRUE))
2271                                 {
2272                                         ident = TRUE;
2273                                 }
2274                         }
2275                         break;
2276                 }
2277
2278                 case SV_STAFF_TELEPORTATION:
2279                 {
2280                         teleport_player(100);
2281                         ident = TRUE;
2282                         break;
2283                 }
2284
2285                 case SV_STAFF_IDENTIFY:
2286                 {
2287                         if (!ident_spell(FALSE)) *use_charge = FALSE;
2288                         ident = TRUE;
2289                         break;
2290                 }
2291
2292                 case SV_STAFF_REMOVE_CURSE:
2293                 {
2294                         if (remove_curse())
2295                         {
2296                                 if (magic)
2297                                 {
2298 #ifdef JP
2299                                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
2300 #else
2301                                         msg_print("You feel as if someone is watching over you.");
2302 #endif
2303                                 }
2304                                 else if (!p_ptr->blind)
2305                                 {
2306 #ifdef JP
2307                                         msg_print("¾ó¤Ï°ì½Ö¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
2308 #else
2309                                         msg_print("The staff glows blue for a moment...");
2310 #endif
2311
2312                                 }
2313                                 ident = TRUE;
2314                         }
2315                         break;
2316                 }
2317
2318                 case SV_STAFF_STARLITE:
2319                 {
2320                         int num = damroll(5, 3);
2321                         int y, x;
2322                         int attempts;
2323
2324                         if (!p_ptr->blind && !magic)
2325                         {
2326 #ifdef JP
2327                                 msg_print("¾ó¤ÎÀ褬ÌÀ¤ë¤¯µ±¤¤¤¿...");
2328 #else
2329                                 msg_print("The end of the staff glows brightly...");
2330 #endif
2331
2332                         }
2333                         for (k = 0; k < num; k++)
2334                         {
2335                 attempts = 1000;
2336
2337                                 while(attempts--)
2338                                 {
2339                                         scatter(&y, &x, py, px, 4, 0);
2340
2341                                         if (!cave_floor_bold(y, x)) continue;
2342
2343                                         if ((y != py) || (x != px)) break;
2344                                 }
2345
2346                                 project(0, 0, y, x, damroll(6 + p_ptr->lev / 8, 10), GF_LITE_WEAK,
2347                                                   (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_KILL), -1);
2348                         }
2349                         ident = TRUE;
2350                         break;
2351                 }
2352
2353                 case SV_STAFF_LITE:
2354                 {
2355                         if (lite_area(damroll(2, 8), 2)) ident = TRUE;
2356                         break;
2357                 }
2358
2359                 case SV_STAFF_MAPPING:
2360                 {
2361                         map_area(DETECT_RAD_MAP);
2362                         ident = TRUE;
2363                         break;
2364                 }
2365
2366                 case SV_STAFF_DETECT_GOLD:
2367                 {
2368                         if (detect_treasure(DETECT_RAD_DEFAULT)) ident = TRUE;
2369                         if (detect_objects_gold(DETECT_RAD_DEFAULT)) ident = TRUE;
2370                         break;
2371                 }
2372
2373                 case SV_STAFF_DETECT_ITEM:
2374                 {
2375                         if (detect_objects_normal(DETECT_RAD_DEFAULT)) ident = TRUE;
2376                         break;
2377                 }
2378
2379                 case SV_STAFF_DETECT_TRAP:
2380                 {
2381                         if (detect_traps(DETECT_RAD_DEFAULT)) ident = TRUE;
2382                         break;
2383                 }
2384
2385                 case SV_STAFF_DETECT_DOOR:
2386                 {
2387                         if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
2388                         if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
2389                         break;
2390                 }
2391
2392                 case SV_STAFF_DETECT_INVIS:
2393                 {
2394                         if (detect_monsters_invis(DETECT_RAD_DEFAULT)) ident = TRUE;
2395                         break;
2396                 }
2397
2398                 case SV_STAFF_DETECT_EVIL:
2399                 {
2400                         if (detect_monsters_evil(DETECT_RAD_DEFAULT)) ident = TRUE;
2401                         break;
2402                 }
2403
2404                 case SV_STAFF_CURE_LIGHT:
2405                 {
2406                         if (hp_player(damroll(2, 8))) ident = TRUE;
2407                         if (set_shero(0,TRUE)) ident = TRUE;
2408                         break;
2409                 }
2410
2411                 case SV_STAFF_CURING:
2412                 {
2413                         if (set_blind(0)) ident = TRUE;
2414                         if (set_poisoned(0)) ident = TRUE;
2415                         if (set_confused(0)) ident = TRUE;
2416                         if (set_stun(0)) ident = TRUE;
2417                         if (set_cut(0)) ident = TRUE;
2418                         if (set_image(0)) ident = TRUE;
2419                         if (set_shero(0,TRUE)) ident = TRUE;
2420                         break;
2421                 }
2422
2423                 case SV_STAFF_HEALING:
2424                 {
2425                         if (hp_player(300)) ident = TRUE;
2426                         if (set_stun(0)) ident = TRUE;
2427                         if (set_cut(0)) ident = TRUE;
2428                         if (set_shero(0,TRUE)) ident = TRUE;
2429                         break;
2430                 }
2431
2432                 case SV_STAFF_THE_MAGI:
2433                 {
2434                         if (do_res_stat(A_INT)) ident = TRUE;
2435                         if (p_ptr->csp < p_ptr->msp)
2436                         {
2437                                 p_ptr->csp = p_ptr->msp;
2438                                 p_ptr->csp_frac = 0;
2439                                 ident = TRUE;
2440 #ifdef JP
2441                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
2442 #else
2443                                 msg_print("Your feel your head clear.");
2444 #endif
2445
2446                                 p_ptr->redraw |= (PR_MANA);
2447                                 p_ptr->window |= (PW_PLAYER);
2448                                 p_ptr->window |= (PW_SPELL);
2449                         }
2450                         if (set_shero(0,TRUE)) ident = TRUE;
2451                         break;
2452                 }
2453
2454                 case SV_STAFF_SLEEP_MONSTERS:
2455                 {
2456                         if (sleep_monsters()) ident = TRUE;
2457                         break;
2458                 }
2459
2460                 case SV_STAFF_SLOW_MONSTERS:
2461                 {
2462                         if (slow_monsters()) ident = TRUE;
2463                         break;
2464                 }
2465
2466                 case SV_STAFF_SPEED:
2467                 {
2468                         if (set_fast(randint(30) + 15, FALSE)) ident = TRUE;
2469                         break;
2470                 }
2471
2472                 case SV_STAFF_PROBING:
2473                 {
2474                         probing();
2475                         ident = TRUE;
2476                         break;
2477                 }
2478
2479                 case SV_STAFF_DISPEL_EVIL:
2480                 {
2481                         if (dispel_evil(80)) ident = TRUE;
2482                         break;
2483                 }
2484
2485                 case SV_STAFF_POWER:
2486                 {
2487                         if (dispel_monsters(150)) ident = TRUE;
2488                         break;
2489                 }
2490
2491                 case SV_STAFF_HOLINESS:
2492                 {
2493                         if (dispel_evil(150)) ident = TRUE;
2494                         k = 3 * p_ptr->lev;
2495                         if (set_protevil((magic ? 0 : p_ptr->protevil) + randint(25) + k, FALSE)) ident = TRUE;
2496                         if (set_poisoned(0)) ident = TRUE;
2497                         if (set_afraid(0)) ident = TRUE;
2498                         if (hp_player(50)) ident = TRUE;
2499                         if (set_stun(0)) ident = TRUE;
2500                         if (set_cut(0)) ident = TRUE;
2501                         break;
2502                 }
2503
2504                 case SV_STAFF_GENOCIDE:
2505                 {
2506                         (void)symbol_genocide((magic ? p_ptr->lev + 50 : 200), TRUE);
2507                         ident = TRUE;
2508                         break;
2509                 }
2510
2511                 case SV_STAFF_EARTHQUAKES:
2512                 {
2513                         if (earthquake(py, px, 10))
2514                                 ident = TRUE;
2515                         else
2516 #ifdef JP
2517 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Íɤ줿¡£");
2518 #else
2519                                 msg_print("The dungeon trembles.");
2520 #endif
2521
2522
2523                         break;
2524                 }
2525
2526                 case SV_STAFF_DESTRUCTION:
2527                 {
2528                         if (destroy_area(py, px, 13+rand_int(5), TRUE))
2529                                 ident = TRUE;
2530
2531                         break;
2532                 }
2533
2534                 case SV_STAFF_ANIMATE_DEAD:
2535                 {
2536                         if (animate_dead(0, py, px))
2537                                 ident = TRUE;
2538
2539                         break;
2540                 }
2541
2542                 case SV_STAFF_MSTORM:
2543                 {
2544 #ifdef JP
2545                         msg_print("¶¯ÎϤÊËâÎϤ¬Å¨¤ò°ú¤­Îö¤¤¤¿¡ª");
2546 #else
2547                         msg_print("Mighty magics rend your enemies!");
2548 #endif
2549                         project(0, 5, py, px,
2550                                 (randint(200) + 300) * 2, GF_MANA, PROJECT_KILL | PROJECT_ITEM | PROJECT_GRID | PROJECT_NO_REF, -1);
2551                         if ((p_ptr->pclass != CLASS_MAGE) && (p_ptr->pclass != CLASS_HIGH_MAGE) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_MAGIC_EATER) && (p_ptr->pclass != CLASS_BLUE_MAGE))
2552                         {
2553 #ifdef JP
2554                                 (void)take_hit(DAMAGE_NOESCAPE, 50, "¥³¥ó¥È¥í¡¼¥ë¤·Æñ¤¤¶¯ÎϤÊËâÎϤβòÊü", -1);
2555 #else
2556                                 (void)take_hit(DAMAGE_NOESCAPE, 50, "unleashing magics too mighty to control", -1);
2557 #endif
2558                         }
2559                         ident = TRUE;
2560
2561                         break;
2562                 }
2563         }
2564         return ident;
2565 }
2566
2567 /*
2568  * Use a staff.                 -RAK-
2569  *
2570  * One charge of one staff disappears.
2571  *
2572  * Hack -- staffs of identify can be "cancelled".
2573  */
2574 static void do_cmd_use_staff_aux(int item)
2575 {
2576         int         ident, chance, lev;
2577         object_type *o_ptr;
2578
2579
2580         /* Hack -- let staffs of identify get aborted */
2581         bool use_charge = TRUE;
2582
2583
2584         /* Get the item (in the pack) */
2585         if (item >= 0)
2586         {
2587                 o_ptr = &inventory[item];
2588         }
2589
2590         /* Get the item (on the floor) */
2591         else
2592         {
2593                 o_ptr = &o_list[0 - item];
2594         }
2595
2596
2597         /* Mega-Hack -- refuse to use a pile from the ground */
2598         if ((item < 0) && (o_ptr->number > 1))
2599         {
2600 #ifdef JP
2601                 msg_print("¤Þ¤º¤Ï¾ó¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
2602 #else
2603                 msg_print("You must first pick up the staffs.");
2604 #endif
2605
2606                 return;
2607         }
2608
2609
2610         /* Take a turn */
2611         energy_use = 100;
2612
2613         /* Extract the item level */
2614         lev = get_object_level(o_ptr);
2615         if (lev > 50) lev = 50 + (lev - 50)/2;
2616
2617         /* Base chance of success */
2618         chance = p_ptr->skill_dev;
2619
2620         /* Confusion hurts skill */
2621         if (p_ptr->confused) chance = chance / 2;
2622
2623         /* Hight level objects are harder */
2624         chance = chance - lev;
2625
2626         /* Give everyone a (slight) chance */
2627         if ((chance < USE_DEVICE) && (rand_int(USE_DEVICE - chance + 1) == 0))
2628         {
2629                 chance = USE_DEVICE;
2630         }
2631
2632         if (world_player)
2633         {
2634                 if (flush_failure) flush();
2635 #ifdef JP
2636                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
2637 #else
2638                 msg_print("Nothing happen. Maybe this staff is freezing too.");
2639 #endif
2640
2641                 sound(SOUND_FAIL);
2642                 return;
2643         }
2644
2645         /* Roll for usage */
2646         if ((chance < USE_DEVICE) || (randint(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
2647         {
2648                 if (flush_failure) flush();
2649 #ifdef JP
2650                 msg_print("¾ó¤ò¤¦¤Þ¤¯»È¤¨¤Ê¤«¤Ã¤¿¡£");
2651 #else
2652                 msg_print("You failed to use the staff properly.");
2653 #endif
2654
2655                 sound(SOUND_FAIL);
2656                 return;
2657         }
2658
2659         /* Notice empty staffs */
2660         if (o_ptr->pval <= 0)
2661         {
2662                 if (flush_failure) flush();
2663 #ifdef JP
2664                 msg_print("¤³¤Î¾ó¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
2665 #else
2666                 msg_print("The staff has no charges left.");
2667 #endif
2668
2669                 o_ptr->ident |= (IDENT_EMPTY);
2670
2671                 /* Combine / Reorder the pack (later) */
2672                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2673
2674                 return;
2675         }
2676
2677
2678         /* Sound */
2679         sound(SOUND_ZAP);
2680
2681         ident = staff_effect(o_ptr->sval, &use_charge, FALSE);
2682
2683         if (!(object_aware_p(o_ptr)))
2684         {
2685                 chg_virtue(V_PATIENCE, -1);
2686                 chg_virtue(V_CHANCE, 1);
2687                 chg_virtue(V_KNOWLEDGE, -1);
2688         }
2689
2690         /* Combine / Reorder the pack (later) */
2691         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2692
2693         /* Tried the item */
2694         object_tried(o_ptr);
2695
2696         /* An identification was made */
2697         if (ident && !object_aware_p(o_ptr))
2698         {
2699                 object_aware(o_ptr);
2700                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
2701         }
2702
2703         /* Window stuff */
2704         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2705
2706
2707         /* Hack -- some uses are "free" */
2708         if (!use_charge) return;
2709
2710
2711         /* Use a single charge */
2712         o_ptr->pval--;
2713
2714         /* XXX Hack -- unstack if necessary */
2715         if ((item >= 0) && (o_ptr->number > 1))
2716         {
2717                 object_type forge;
2718                 object_type *q_ptr;
2719
2720                 /* Get local object */
2721                 q_ptr = &forge;
2722
2723                 /* Obtain a local object */
2724                 object_copy(q_ptr, o_ptr);
2725
2726                 /* Modify quantity */
2727                 q_ptr->number = 1;
2728
2729                 /* Restore the charges */
2730                 o_ptr->pval++;
2731
2732                 /* Unstack the used item */
2733                 o_ptr->number--;
2734                 p_ptr->total_weight -= q_ptr->weight;
2735                 item = inven_carry(q_ptr);
2736
2737                 /* Message */
2738 #ifdef JP
2739                 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
2740 #else
2741                 msg_print("You unstack your staff.");
2742 #endif
2743
2744         }
2745
2746         /* Describe charges in the pack */
2747         if (item >= 0)
2748         {
2749                 inven_item_charges(item);
2750         }
2751
2752         /* Describe charges on the floor */
2753         else
2754         {
2755                 floor_item_charges(0 - item);
2756         }
2757 }
2758
2759
2760 void do_cmd_use_staff(void)
2761 {
2762         int  item;
2763         cptr q, s;
2764
2765         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
2766         {
2767                 set_action(ACTION_NONE);
2768         }
2769
2770         /* Restrict choices to wands */
2771         item_tester_tval = TV_STAFF;
2772
2773         /* Get an item */
2774 #ifdef JP
2775         q = "¤É¤Î¾ó¤ò»È¤¤¤Þ¤¹¤«? ";
2776         s = "»È¤¨¤ë¾ó¤¬¤Ê¤¤¡£";
2777 #else
2778         q = "Use which staff? ";
2779         s = "You have no staff to use.";
2780 #endif
2781
2782         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
2783
2784         do_cmd_use_staff_aux(item);
2785 }
2786
2787
2788 static int wand_effect(int sval, int dir, bool magic)
2789 {
2790         int ident = FALSE;
2791
2792         /* XXX Hack -- Wand of wonder can do anything before it */
2793         if (sval == SV_WAND_WONDER)
2794         {
2795                 int vir = virtue_number(V_CHANCE);
2796                 sval = rand_int(SV_WAND_WONDER);
2797
2798                 if (vir)
2799                 {
2800                         if (p_ptr->virtues[vir - 1] > 0)
2801                         {
2802                                 while (randint(300) < p_ptr->virtues[vir - 1]) sval++;
2803                                 if (sval > SV_WAND_COLD_BALL) sval = rand_int(4) + SV_WAND_ACID_BALL;
2804                         }
2805                         else
2806                         {
2807                                 while (randint(300) < (0-p_ptr->virtues[vir - 1])) sval--;
2808                                 if (sval < SV_WAND_HEAL_MONSTER) sval = rand_int(3) + SV_WAND_HEAL_MONSTER;
2809                         }
2810                 }
2811                 if (sval < SV_WAND_TELEPORT_AWAY)
2812                         chg_virtue(V_CHANCE, 1);
2813         }
2814
2815         /* Analyze the wand */
2816         switch (sval)
2817         {
2818                 case SV_WAND_HEAL_MONSTER:
2819                 {
2820                         if (heal_monster(dir, damroll(10, 10))) ident = TRUE;
2821                         break;
2822                 }
2823
2824                 case SV_WAND_HASTE_MONSTER:
2825                 {
2826                         if (speed_monster(dir)) ident = TRUE;
2827                         break;
2828                 }
2829
2830                 case SV_WAND_CLONE_MONSTER:
2831                 {
2832                         if (clone_monster(dir)) ident = TRUE;
2833                         break;
2834                 }
2835
2836                 case SV_WAND_TELEPORT_AWAY:
2837                 {
2838                         if (teleport_monster(dir)) ident = TRUE;
2839                         break;
2840                 }
2841
2842                 case SV_WAND_DISARMING:
2843                 {
2844                         if (disarm_trap(dir)) ident = TRUE;
2845                         break;
2846                 }
2847
2848                 case SV_WAND_TRAP_DOOR_DEST:
2849                 {
2850                         if (destroy_door(dir)) ident = TRUE;
2851                         break;
2852                 }
2853
2854                 case SV_WAND_STONE_TO_MUD:
2855                 {
2856                         if (wall_to_mud(dir)) ident = TRUE;
2857                         break;
2858                 }
2859
2860                 case SV_WAND_LITE:
2861                 {
2862 #ifdef JP
2863                         msg_print("ÀĤ¯µ±¤¯¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
2864 #else
2865                         msg_print("A line of blue shimmering light appears.");
2866 #endif
2867
2868                         (void)lite_line(dir);
2869                         ident = TRUE;
2870                         break;
2871                 }
2872
2873                 case SV_WAND_SLEEP_MONSTER:
2874                 {
2875                         if (sleep_monster(dir)) ident = TRUE;
2876                         break;
2877                 }
2878
2879                 case SV_WAND_SLOW_MONSTER:
2880                 {
2881                         if (slow_monster(dir)) ident = TRUE;
2882                         break;
2883                 }
2884
2885                 case SV_WAND_CONFUSE_MONSTER:
2886                 {
2887                         if (confuse_monster(dir, p_ptr->lev)) ident = TRUE;
2888                         break;
2889                 }
2890
2891                 case SV_WAND_FEAR_MONSTER:
2892                 {
2893                         if (fear_monster(dir, p_ptr->lev)) ident = TRUE;
2894                         break;
2895                 }
2896
2897                 case SV_WAND_DRAIN_LIFE:
2898                 {
2899                         if (drain_life(dir, 80 + p_ptr->lev)) ident = TRUE;
2900                         break;
2901                 }
2902
2903                 case SV_WAND_POLYMORPH:
2904                 {
2905                         if (poly_monster(dir)) ident = TRUE;
2906                         break;
2907                 }
2908
2909                 case SV_WAND_STINKING_CLOUD:
2910                 {
2911                         fire_ball(GF_POIS, dir, 12 + p_ptr->lev / 4, 2);
2912                         ident = TRUE;
2913                         break;
2914                 }
2915
2916                 case SV_WAND_MAGIC_MISSILE:
2917                 {
2918                         fire_bolt_or_beam(20, GF_MISSILE, dir, damroll(2 + p_ptr->lev / 10, 6));
2919                         ident = TRUE;
2920                         break;
2921                 }
2922
2923                 case SV_WAND_ACID_BOLT:
2924                 {
2925                         fire_bolt_or_beam(20, GF_ACID, dir, damroll(6 + p_ptr->lev / 7, 8));
2926                         ident = TRUE;
2927                         break;
2928                 }
2929
2930                 case SV_WAND_CHARM_MONSTER:
2931                 {
2932                         if (charm_monster(dir, MAX(20, p_ptr->lev)))
2933                         ident = TRUE;
2934                         break;
2935                 }
2936
2937                 case SV_WAND_FIRE_BOLT:
2938                 {
2939                         fire_bolt_or_beam(20, GF_FIRE, dir, damroll(7 + p_ptr->lev / 6, 8));
2940                         ident = TRUE;
2941                         break;
2942                 }
2943
2944                 case SV_WAND_COLD_BOLT:
2945                 {
2946                         fire_bolt_or_beam(20, GF_COLD, dir, damroll(5 + p_ptr->lev / 8, 8));
2947                         ident = TRUE;
2948                         break;
2949                 }
2950
2951                 case SV_WAND_ACID_BALL:
2952                 {
2953                         fire_ball(GF_ACID, dir, 60 + 3 * p_ptr->lev / 4, 2);
2954                         ident = TRUE;
2955                         break;
2956                 }
2957
2958                 case SV_WAND_ELEC_BALL:
2959                 {
2960                         fire_ball(GF_ELEC, dir, 40 + 3 * p_ptr->lev / 4, 2);
2961                         ident = TRUE;
2962                         break;
2963                 }
2964
2965                 case SV_WAND_FIRE_BALL:
2966                 {
2967                         fire_ball(GF_FIRE, dir, 70 + 3 * p_ptr->lev / 4, 2);
2968                         ident = TRUE;
2969                         break;
2970                 }
2971
2972                 case SV_WAND_COLD_BALL:
2973                 {
2974                         fire_ball(GF_COLD, dir, 50 + 3 * p_ptr->lev / 4, 2);
2975                         ident = TRUE;
2976                         break;
2977                 }
2978
2979                 case SV_WAND_WONDER:
2980                 {
2981 #ifdef JP
2982                         msg_print("¤ª¤Ã¤È¡¢Ææ¤ÎËâË¡ËÀ¤ò»ÏÆ°¤µ¤»¤¿¡£");
2983 #else
2984                         msg_print("Oops.  Wand of wonder activated.");
2985 #endif
2986
2987                         break;
2988                 }
2989
2990                 case SV_WAND_DRAGON_FIRE:
2991                 {
2992                         fire_ball(GF_FIRE, dir, 200, -3);
2993                         ident = TRUE;
2994                         break;
2995                 }
2996
2997                 case SV_WAND_DRAGON_COLD:
2998                 {
2999                         fire_ball(GF_COLD, dir, 180, -3);
3000                         ident = TRUE;
3001                         break;
3002                 }
3003
3004                 case SV_WAND_DRAGON_BREATH:
3005                 {
3006                         switch (randint(5))
3007                         {
3008                                 case 1:
3009                                 {
3010                                         fire_ball(GF_ACID, dir, 240, -3);
3011                                         break;
3012                                 }
3013
3014                                 case 2:
3015                                 {
3016                                         fire_ball(GF_ELEC, dir, 210, -3);
3017                                         break;
3018                                 }
3019
3020                                 case 3:
3021                                 {
3022                                         fire_ball(GF_FIRE, dir, 240, -3);
3023                                         break;
3024                                 }
3025
3026                                 case 4:
3027                                 {
3028                                         fire_ball(GF_COLD, dir, 210, -3);
3029                                         break;
3030                                 }
3031
3032                                 default:
3033                                 {
3034                                         fire_ball(GF_POIS, dir, 180, -3);
3035                                         break;
3036                                 }
3037                         }
3038
3039                         ident = TRUE;
3040                         break;
3041                 }
3042
3043 //              case SV_WAND_ANNIHILATION:
3044                 case SV_WAND_DISINTEGRATE:
3045                 {
3046                         fire_ball(GF_DISINTEGRATE, dir, 200 + randint(p_ptr->lev * 2), 2);
3047                         ident = TRUE;
3048                         break;
3049                 }
3050
3051                 case SV_WAND_ROCKETS:
3052                 {
3053 #ifdef JP
3054 msg_print("¥í¥±¥Ã¥È¤òȯ¼Í¤·¤¿¡ª");
3055 #else
3056                         msg_print("You launch a rocket!");
3057 #endif
3058
3059                         fire_rocket(GF_ROCKET, dir, 250 + p_ptr->lev * 3, 2);
3060                         ident = TRUE;
3061                         break;
3062                 }
3063
3064                 case SV_WAND_STRIKING:
3065                 {
3066                         fire_bolt(GF_METEOR, dir, damroll(15 + p_ptr->lev / 3, 13));
3067                         ident = TRUE;
3068                         break;
3069                 }
3070
3071                 case SV_WAND_GENOCIDE:
3072                 {
3073                         fire_ball_hide(GF_GENOCIDE, dir, magic ? p_ptr->lev + 50 : 250, 0);
3074                         ident = TRUE;
3075                         break;
3076                 }
3077         }
3078         return ident;
3079 }
3080
3081
3082 /*
3083  * Aim a wand (from the pack or floor).
3084  *
3085  * Use a single charge from a single item.
3086  * Handle "unstacking" in a logical manner.
3087  *
3088  * For simplicity, you cannot use a stack of items from the
3089  * ground.  This would require too much nasty code.
3090  *
3091  * There are no wands which can "destroy" themselves, in the inventory
3092  * or on the ground, so we can ignore this possibility.  Note that this
3093  * required giving "wand of wonder" the ability to ignore destruction
3094  * by electric balls.
3095  *
3096  * All wands can be "cancelled" at the "Direction?" prompt for free.
3097  *
3098  * Note that the basic "bolt" wands do slightly less damage than the
3099  * basic "bolt" rods, but the basic "ball" wands do the same damage
3100  * as the basic "ball" rods.
3101  */
3102 static void do_cmd_aim_wand_aux(int item)
3103 {
3104         int         lev, ident, chance, dir;
3105         object_type *o_ptr;
3106         bool old_target_pet = target_pet;
3107
3108         /* Get the item (in the pack) */
3109         if (item >= 0)
3110         {
3111                 o_ptr = &inventory[item];
3112         }
3113
3114         /* Get the item (on the floor) */
3115         else
3116         {
3117                 o_ptr = &o_list[0 - item];
3118         }
3119
3120         /* Mega-Hack -- refuse to aim a pile from the ground */
3121         if ((item < 0) && (o_ptr->number > 1))
3122         {
3123 #ifdef JP
3124                 msg_print("¤Þ¤º¤ÏËâË¡ËÀ¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
3125 #else
3126                 msg_print("You must first pick up the wands.");
3127 #endif
3128
3129                 return;
3130         }
3131
3132
3133         /* Allow direction to be cancelled for free */
3134         if (object_aware_p(o_ptr) && (o_ptr->sval == SV_WAND_HEAL_MONSTER
3135                                       || o_ptr->sval == SV_WAND_HASTE_MONSTER))
3136                         target_pet = TRUE;
3137         if (!get_aim_dir(&dir))
3138         {
3139                 target_pet = old_target_pet;
3140                 return;
3141         }
3142         target_pet = old_target_pet;
3143
3144         /* Take a turn */
3145         energy_use = 100;
3146
3147         /* Get the level */
3148         lev = get_object_level(o_ptr);
3149         if (lev > 50) lev = 50 + (lev - 50)/2;
3150
3151         /* Base chance of success */
3152         chance = p_ptr->skill_dev;
3153
3154         /* Confusion hurts skill */
3155         if (p_ptr->confused) chance = chance / 2;
3156
3157         /* Hight level objects are harder */
3158         chance = chance - lev;
3159
3160         /* Give everyone a (slight) chance */
3161         if ((chance < USE_DEVICE) && (rand_int(USE_DEVICE - chance + 1) == 0))
3162         {
3163                 chance = USE_DEVICE;
3164         }
3165
3166         if (world_player)
3167         {
3168                 if (flush_failure) flush();
3169 #ifdef JP
3170                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
3171 #else
3172                 msg_print("Nothing happen. Maybe this wand is freezing too.");
3173 #endif
3174
3175                 sound(SOUND_FAIL);
3176                 return;
3177         }
3178
3179         /* Roll for usage */
3180         if ((chance < USE_DEVICE) || (randint(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
3181         {
3182                 if (flush_failure) flush();
3183 #ifdef JP
3184                 msg_print("ËâË¡ËÀ¤ò¤¦¤Þ¤¯»È¤¨¤Ê¤«¤Ã¤¿¡£");
3185 #else
3186                 msg_print("You failed to use the wand properly.");
3187 #endif
3188
3189                 sound(SOUND_FAIL);
3190                 return;
3191         }
3192
3193         /* The wand is already empty! */
3194         if (o_ptr->pval <= 0)
3195         {
3196                 if (flush_failure) flush();
3197 #ifdef JP
3198                 msg_print("¤³¤ÎËâË¡ËÀ¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
3199 #else
3200                 msg_print("The wand has no charges left.");
3201 #endif
3202
3203                 o_ptr->ident |= (IDENT_EMPTY);
3204
3205                 /* Combine / Reorder the pack (later) */
3206                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3207
3208                 return;
3209         }
3210
3211         /* Sound */
3212         sound(SOUND_ZAP);
3213
3214         ident = wand_effect(o_ptr->sval, dir, FALSE);
3215
3216         /* Combine / Reorder the pack (later) */
3217         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3218
3219         if (!(object_aware_p(o_ptr)))
3220         {
3221                 chg_virtue(V_PATIENCE, -1);
3222                 chg_virtue(V_CHANCE, 1);
3223                 chg_virtue(V_KNOWLEDGE, -1);
3224         }
3225
3226         /* Mark it as tried */
3227         object_tried(o_ptr);
3228
3229         /* Apply identification */
3230         if (ident && !object_aware_p(o_ptr))
3231         {
3232                 object_aware(o_ptr);
3233                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
3234         }
3235
3236         /* Window stuff */
3237         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
3238
3239
3240         /* Use a single charge */
3241         o_ptr->pval--;
3242
3243         /* Describe the charges in the pack */
3244         if (item >= 0)
3245         {
3246                 inven_item_charges(item);
3247         }
3248
3249         /* Describe the charges on the floor */
3250         else
3251         {
3252                 floor_item_charges(0 - item);
3253         }
3254 }
3255
3256
3257 void do_cmd_aim_wand(void)
3258 {
3259         int     item;
3260         cptr    q, s;
3261
3262         /* Restrict choices to wands */
3263         item_tester_tval = TV_WAND;
3264
3265         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
3266         {
3267                 set_action(ACTION_NONE);
3268         }
3269
3270         /* Get an item */
3271 #ifdef JP
3272         q = "¤É¤ÎËâË¡ËÀ¤ÇÁÀ¤¤¤Þ¤¹¤«? ";
3273         s = "»È¤¨¤ëËâË¡ËÀ¤¬¤Ê¤¤¡£";
3274 #else
3275         q = "Aim which wand? ";
3276         s = "You have no wand to aim.";
3277 #endif
3278
3279         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
3280
3281         /* Aim the wand */
3282         do_cmd_aim_wand_aux(item);
3283 }
3284
3285
3286 static int rod_effect(int sval, int dir, bool *use_charge, bool magic)
3287 {
3288         int ident = FALSE;
3289
3290         /* Analyze the rod */
3291         switch (sval)
3292         {
3293                 case SV_ROD_DETECT_TRAP:
3294                 {
3295                         if (detect_traps(DETECT_RAD_DEFAULT)) ident = TRUE;
3296                         break;
3297                 }
3298
3299                 case SV_ROD_DETECT_DOOR:
3300                 {
3301                         if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
3302                         if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
3303                         break;
3304                 }
3305
3306                 case SV_ROD_IDENTIFY:
3307                 {
3308                         ident = TRUE;
3309                         if (!ident_spell(FALSE)) *use_charge = FALSE;
3310                         break;
3311                 }
3312
3313                 case SV_ROD_RECALL:
3314                 {
3315                         if (!word_of_recall()) *use_charge = FALSE;
3316                         ident = TRUE;
3317                         break;
3318                 }
3319
3320                 case SV_ROD_ILLUMINATION:
3321                 {
3322                         if (lite_area(damroll(2, 8), 2)) ident = TRUE;
3323                         break;
3324                 }
3325
3326                 case SV_ROD_MAPPING:
3327                 {
3328                         map_area(DETECT_RAD_MAP);
3329                         ident = TRUE;
3330                         break;
3331                 }
3332
3333                 case SV_ROD_DETECTION:
3334                 {
3335                         detect_all(DETECT_RAD_DEFAULT);
3336                         ident = TRUE;
3337                         break;
3338                 }
3339
3340                 case SV_ROD_PROBING:
3341                 {
3342                         probing();
3343                         ident = TRUE;
3344                         break;
3345                 }
3346
3347                 case SV_ROD_CURING:
3348                 {
3349                         if (set_blind(0)) ident = TRUE;
3350                         if (set_poisoned(0)) ident = TRUE;
3351                         if (set_confused(0)) ident = TRUE;
3352                         if (set_stun(0)) ident = TRUE;
3353                         if (set_cut(0)) ident = TRUE;
3354                         if (set_image(0)) ident = TRUE;
3355                         if (set_shero(0,TRUE)) ident = TRUE;
3356                         break;
3357                 }
3358
3359                 case SV_ROD_HEALING:
3360                 {
3361                         if (hp_player(500)) ident = TRUE;
3362                         if (set_stun(0)) ident = TRUE;
3363                         if (set_cut(0)) ident = TRUE;
3364                         if (set_shero(0,TRUE)) ident = TRUE;
3365                         break;
3366                 }
3367
3368                 case SV_ROD_RESTORATION:
3369                 {
3370                         if (restore_level()) ident = TRUE;
3371                         if (do_res_stat(A_STR)) ident = TRUE;
3372                         if (do_res_stat(A_INT)) ident = TRUE;
3373                         if (do_res_stat(A_WIS)) ident = TRUE;
3374                         if (do_res_stat(A_DEX)) ident = TRUE;
3375                         if (do_res_stat(A_CON)) ident = TRUE;
3376                         if (do_res_stat(A_CHR)) ident = TRUE;
3377                         break;
3378                 }
3379
3380                 case SV_ROD_SPEED:
3381                 {
3382                         if (set_fast(randint(30) + 15, FALSE)) ident = TRUE;
3383                         break;
3384                 }
3385
3386                 case SV_ROD_PESTICIDE:
3387                 {
3388                         fire_ball(GF_POIS, dir, 10, 3);
3389                         ident = TRUE;
3390                         break;
3391                 }
3392
3393                 case SV_ROD_TELEPORT_AWAY:
3394                 {
3395                         if (teleport_monster(dir)) ident = TRUE;
3396                         break;
3397                 }
3398
3399                 case SV_ROD_DISARMING:
3400                 {
3401                         if (disarm_trap(dir)) ident = TRUE;
3402                         break;
3403                 }
3404
3405                 case SV_ROD_LITE:
3406                 {
3407 #ifdef JP
3408                         msg_print("ÀĤ¯µ±¤¯¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
3409 #else
3410                         msg_print("A line of blue shimmering light appears.");
3411 #endif
3412
3413                         (void)lite_line(dir);
3414                         ident = TRUE;
3415                         break;
3416                 }
3417
3418                 case SV_ROD_SLEEP_MONSTER:
3419                 {
3420                         if (sleep_monster(dir)) ident = TRUE;
3421                         break;
3422                 }
3423
3424                 case SV_ROD_SLOW_MONSTER:
3425                 {
3426                         if (slow_monster(dir)) ident = TRUE;
3427                         break;
3428                 }
3429
3430                 case SV_ROD_DRAIN_LIFE:
3431                 {
3432                         if (drain_life(dir, 70 + 3 * p_ptr->lev / 2)) ident = TRUE;
3433                         break;
3434                 }
3435
3436                 case SV_ROD_POLYMORPH:
3437                 {
3438                         if (poly_monster(dir)) ident = TRUE;
3439                         break;
3440                 }
3441
3442                 case SV_ROD_ACID_BOLT:
3443                 {
3444                         fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + p_ptr->lev / 7, 8));
3445                         ident = TRUE;
3446                         break;
3447                 }
3448
3449                 case SV_ROD_ELEC_BOLT:
3450                 {
3451                         fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + p_ptr->lev / 9, 8));
3452                         ident = TRUE;
3453                         break;
3454                 }
3455
3456                 case SV_ROD_FIRE_BOLT:
3457                 {
3458                         fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + p_ptr->lev / 6, 8));
3459                         ident = TRUE;
3460                         break;
3461                 }
3462
3463                 case SV_ROD_COLD_BOLT:
3464                 {
3465                         fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + p_ptr->lev / 8, 8));
3466                         ident = TRUE;
3467                         break;
3468                 }
3469
3470                 case SV_ROD_ACID_BALL:
3471                 {
3472                         fire_ball(GF_ACID, dir, 60 + p_ptr->lev, 2);
3473                         ident = TRUE;
3474                         break;
3475                 }
3476
3477                 case SV_ROD_ELEC_BALL:
3478                 {
3479                         fire_ball(GF_ELEC, dir, 40 + p_ptr->lev, 2);
3480                         ident = TRUE;
3481                         break;
3482                 }
3483
3484                 case SV_ROD_FIRE_BALL:
3485                 {
3486                         fire_ball(GF_FIRE, dir, 70 + p_ptr->lev, 2);
3487                         ident = TRUE;
3488                         break;
3489                 }
3490
3491                 case SV_ROD_COLD_BALL:
3492                 {
3493                         fire_ball(GF_COLD, dir, 50 + p_ptr->lev, 2);
3494                         ident = TRUE;
3495                         break;
3496                 }
3497
3498                 case SV_ROD_HAVOC:
3499                 {
3500                         call_chaos();
3501                         ident = TRUE;
3502                         break;
3503                 }
3504
3505                 case SV_ROD_STONE_TO_MUD:
3506                 {
3507                         if (wall_to_mud(dir)) ident = TRUE;
3508                         break;
3509                 }
3510
3511                 case SV_ROD_AGGRAVATE:
3512                 {
3513                         aggravate_monsters(0);
3514                         ident = TRUE;
3515                         break;
3516                 }
3517         }
3518         return ident;
3519 }
3520
3521 /*
3522  * Activate (zap) a Rod
3523  *
3524  * Unstack fully charged rods as needed.
3525  *
3526  * Hack -- rods of perception/genocide can be "cancelled"
3527  * All rods can be cancelled at the "Direction?" prompt
3528  *
3529  * pvals are defined for each rod in k_info. -LM-
3530  */
3531 static void do_cmd_zap_rod_aux(int item)
3532 {
3533         int         ident, chance, dir, lev, fail;
3534         object_type *o_ptr;
3535         bool success;
3536
3537         /* Hack -- let perception get aborted */
3538         bool use_charge = TRUE;
3539
3540         object_kind *k_ptr;
3541
3542         /* Get the item (in the pack) */
3543         if (item >= 0)
3544         {
3545                 o_ptr = &inventory[item];
3546         }
3547
3548         /* Get the item (on the floor) */
3549         else
3550         {
3551                 o_ptr = &o_list[0 - item];
3552         }
3553
3554
3555         /* Mega-Hack -- refuse to zap a pile from the ground */
3556         if ((item < 0) && (o_ptr->number > 1))
3557         {
3558 #ifdef JP
3559                 msg_print("¤Þ¤º¤Ï¥í¥Ã¥É¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
3560 #else
3561                 msg_print("You must first pick up the rods.");
3562 #endif
3563
3564                 return;
3565         }
3566
3567
3568         /* Get a direction (unless KNOWN not to need it) */
3569         if (((o_ptr->sval >= SV_ROD_MIN_DIRECTION) && (o_ptr->sval != SV_ROD_HAVOC) && (o_ptr->sval != SV_ROD_AGGRAVATE)) ||
3570              !object_aware_p(o_ptr))
3571         {
3572                 /* Get a direction, allow cancel */
3573                 if (!get_aim_dir(&dir)) return;
3574         }
3575
3576
3577         /* Take a turn */
3578         energy_use = 100;
3579
3580         /* Extract the item level */
3581         lev = get_object_level(o_ptr);
3582
3583         /* Base chance of success */
3584         chance = p_ptr->skill_dev;
3585
3586         /* Confusion hurts skill */
3587         if (p_ptr->confused) chance = chance / 2;
3588
3589         fail = lev+5;
3590         if (chance > fail) fail -= (chance - fail)*2;
3591         else chance -= (fail - chance)*2;
3592         if (fail < USE_DEVICE) fail = USE_DEVICE;
3593         if (chance < USE_DEVICE) chance = USE_DEVICE;
3594
3595         if (world_player)
3596         {
3597                 if (flush_failure) flush();
3598 #ifdef JP
3599                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
3600 #else
3601                 msg_print("Nothing happen. Maybe this rod is freezing too.");
3602 #endif
3603
3604                 sound(SOUND_FAIL);
3605                 return;
3606         }
3607
3608         if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
3609         else if (chance > fail)
3610         {
3611                 if (rand_int(chance*2) < fail) success = FALSE;
3612                 else success = TRUE;
3613         }
3614         else
3615         {
3616                 if (rand_int(fail*2) < chance) success = TRUE;
3617                 else success = FALSE;
3618         }
3619
3620         /* Roll for usage */
3621         if (!success)
3622         {
3623                 if (flush_failure) flush();
3624 #ifdef JP
3625                 msg_print("¤¦¤Þ¤¯¥í¥Ã¥É¤ò»È¤¨¤Ê¤«¤Ã¤¿¡£");
3626 #else
3627                 msg_print("You failed to use the rod properly.");
3628 #endif
3629
3630                 sound(SOUND_FAIL);
3631                 return;
3632         }
3633
3634         k_ptr = &k_info[o_ptr->k_idx];
3635
3636         /* A single rod is still charging */
3637         if ((o_ptr->number == 1) && (o_ptr->timeout))
3638         {
3639                 if (flush_failure) flush();
3640 #ifdef JP
3641                 msg_print("¤³¤Î¥í¥Ã¥É¤Ï¤Þ¤ÀËâÎϤò½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
3642 #else
3643                 msg_print("The rod is still charging.");
3644 #endif
3645
3646                 return;
3647         }
3648         /* A stack of rods lacks enough energy. */
3649         else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
3650         {
3651                 if (flush_failure) flush();
3652 #ifdef JP
3653 msg_print("¤½¤Î¥í¥Ã¥É¤Ï¤Þ¤À½¼Å¶Ãæ¤Ç¤¹¡£");
3654 #else
3655                 msg_print("The rods are all still charging.");
3656 #endif
3657
3658                 return;
3659         }
3660
3661         /* Sound */
3662         sound(SOUND_ZAP);
3663
3664         ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE);
3665
3666         /* Increase the timeout by the rod kind's pval. -LM- */
3667         if (use_charge) o_ptr->timeout += k_ptr->pval;
3668
3669         /* Combine / Reorder the pack (later) */
3670         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3671
3672         if (!(object_aware_p(o_ptr)))
3673         {
3674                 chg_virtue(V_PATIENCE, -1);
3675                 chg_virtue(V_CHANCE, 1);
3676                 chg_virtue(V_KNOWLEDGE, -1);
3677         }
3678
3679         /* Tried the object */
3680         object_tried(o_ptr);
3681
3682         /* Successfully determined the object function */
3683         if (ident && !object_aware_p(o_ptr))
3684         {
3685                 object_aware(o_ptr);
3686                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
3687         }
3688
3689         /* Window stuff */
3690         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
3691 }
3692
3693
3694 void do_cmd_zap_rod(void)
3695 {
3696         int item;
3697         cptr q, s;
3698
3699         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
3700         {
3701                 set_action(ACTION_NONE);
3702         }
3703
3704         /* Restrict choices to rods */
3705         item_tester_tval = TV_ROD;
3706
3707         /* Get an item */
3708 #ifdef JP
3709         q = "¤É¤Î¥í¥Ã¥É¤ò¿¶¤ê¤Þ¤¹¤«? ";
3710         s = "»È¤¨¤ë¥í¥Ã¥É¤¬¤Ê¤¤¡£";
3711 #else
3712         q = "Zap which rod? ";
3713         s = "You have no rod to zap.";
3714 #endif
3715
3716         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
3717
3718         /* Zap the rod */
3719         do_cmd_zap_rod_aux(item);
3720 }
3721
3722
3723 /*
3724  * Hook to determine if an object is activatable
3725  */
3726 static bool item_tester_hook_activate(object_type *o_ptr)
3727 {
3728         u32b f1, f2, f3;
3729
3730         /* Not known */
3731         if (!object_known_p(o_ptr)) return (FALSE);
3732
3733         /* Extract the flags */
3734         object_flags(o_ptr, &f1, &f2, &f3);
3735
3736         /* Check activation flag */
3737         if (f3 & (TR3_ACTIVATE)) return (TRUE);
3738
3739         if ((o_ptr->tval > TV_CAPTURE) && o_ptr->xtra3)
3740         {
3741                 switch(o_ptr->xtra3)
3742                 case ESSENCE_TMP_RES_ACID:
3743                 case ESSENCE_TMP_RES_ELEC:
3744                 case ESSENCE_TMP_RES_FIRE:
3745                 case ESSENCE_TMP_RES_COLD:
3746                 case ESSENCE_EARTHQUAKE:
3747                         return (TRUE);
3748         }
3749
3750         /* Assume not */
3751         return (FALSE);
3752 }
3753
3754
3755 /*
3756  * Hack -- activate the ring of power
3757  */
3758 void ring_of_power(int dir)
3759 {
3760         /* Pick a random effect */
3761         switch (randint(10))
3762         {
3763                 case 1:
3764                 case 2:
3765                 {
3766                         /* Message */
3767 #ifdef JP
3768                         msg_print("¤¢¤Ê¤¿¤Ï°­À­¤Î¥ª¡¼¥é¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡£");
3769 #else
3770                         msg_print("You are surrounded by a malignant aura.");
3771 #endif
3772
3773                         sound(SOUND_EVIL);
3774
3775                         /* Decrease all stats (permanently) */
3776                         (void)dec_stat(A_STR, 50, TRUE);
3777                         (void)dec_stat(A_INT, 50, TRUE);
3778                         (void)dec_stat(A_WIS, 50, TRUE);
3779                         (void)dec_stat(A_DEX, 50, TRUE);
3780                         (void)dec_stat(A_CON, 50, TRUE);
3781                         (void)dec_stat(A_CHR, 50, TRUE);
3782
3783                         /* Lose some experience (permanently) */
3784                         p_ptr->exp -= (p_ptr->exp / 4);
3785                         p_ptr->max_exp -= (p_ptr->exp / 4);
3786                         check_experience();
3787
3788                         break;
3789                 }
3790
3791                 case 3:
3792                 {
3793                         /* Message */
3794 #ifdef JP
3795                         msg_print("¤¢¤Ê¤¿¤Ï¶¯ÎϤʥª¡¼¥é¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡£");
3796 #else
3797                         msg_print("You are surrounded by a powerful aura.");
3798 #endif
3799
3800
3801                         /* Dispel monsters */
3802                         dispel_monsters(1000);
3803
3804                         break;
3805                 }
3806
3807                 case 4:
3808                 case 5:
3809                 case 6:
3810                 {
3811                         /* Mana Ball */
3812                         fire_ball(GF_MANA, dir, 600, 3);
3813
3814                         break;
3815                 }
3816
3817                 case 7:
3818                 case 8:
3819                 case 9:
3820                 case 10:
3821                 {
3822                         /* Mana Bolt */
3823                         fire_bolt(GF_MANA, dir, 500);
3824
3825                         break;
3826                 }
3827         }
3828 }
3829
3830
3831 static bool ang_sort_comp_pet(vptr u, vptr v, int a, int b)
3832 {
3833         u16b *who = (u16b*)(u);
3834
3835         int w1 = who[a];
3836         int w2 = who[b];
3837
3838         monster_type *m_ptr1 = &m_list[w1];
3839         monster_type *m_ptr2 = &m_list[w2];
3840         monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
3841         monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
3842
3843         if (m_ptr1->nickname && !m_ptr2->nickname) return TRUE;
3844         if (m_ptr2->nickname && !m_ptr1->nickname) return FALSE;
3845
3846         if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return TRUE;
3847         if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return FALSE;
3848
3849         if (r_ptr1->level > r_ptr2->level) return TRUE;
3850         if (r_ptr2->level > r_ptr1->level) return FALSE;
3851
3852         if (m_ptr1->hp > m_ptr2->hp) return TRUE;
3853         if (m_ptr2->hp > m_ptr1->hp) return FALSE;
3854         
3855         return w1 <= w2;
3856 }
3857
3858 /*
3859  * Activate a wielded object.  Wielded objects never stack.
3860  * And even if they did, activatable objects never stack.
3861  *
3862  * Currently, only (some) artifacts, and Dragon Scale Mail, can be activated.
3863  * But one could, for example, easily make an activatable "Ring of Plasma".
3864  *
3865  * Note that it always takes a turn to activate an artifact, even if
3866  * the user hits "escape" at the "direction" prompt.
3867  */
3868 static void do_cmd_activate_aux(int item)
3869 {
3870         int         k, dir, lev, chance, fail;
3871         object_type *o_ptr;
3872         bool success;
3873
3874
3875         /* Get the item (in the pack) */
3876         if (item >= 0)
3877         {
3878                 o_ptr = &inventory[item];
3879         }
3880
3881         /* Get the item (on the floor) */
3882         else
3883         {
3884                 o_ptr = &o_list[0 - item];
3885         }
3886
3887         /* Take a turn */
3888         energy_use = 100;
3889
3890         /* Extract the item level */
3891         lev = get_object_level(o_ptr);
3892
3893         /* Hack -- use artifact level instead */
3894         if (artifact_p(o_ptr)) lev = a_info[o_ptr->name1].level;
3895         else if (((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) && o_ptr->name2) lev = e_info[o_ptr->name2].level;
3896
3897         /* Base chance of success */
3898         chance = p_ptr->skill_dev;
3899
3900         /* Confusion hurts skill */
3901         if (p_ptr->confused) chance = chance / 2;
3902
3903         fail = lev+5;
3904         if (chance > fail) fail -= (chance - fail)*2;
3905         else chance -= (fail - chance)*2;
3906         if (fail < USE_DEVICE) fail = USE_DEVICE;
3907         if (chance < USE_DEVICE) chance = USE_DEVICE;
3908
3909         if (world_player)
3910         {
3911                 if (flush_failure) flush();
3912 #ifdef JP
3913                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
3914 #else
3915                 msg_print("It shows no reaction.");
3916 #endif
3917
3918                 sound(SOUND_FAIL);
3919                 return;
3920         }
3921
3922         if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
3923         else if (chance > fail)
3924         {
3925                 if (rand_int(chance*2) < fail) success = FALSE;
3926                 else success = TRUE;
3927         }
3928         else
3929         {
3930                 if (rand_int(fail*2) < chance) success = TRUE;
3931                 else success = FALSE;
3932         }
3933
3934         /* Roll for usage */
3935         if (!success)
3936         {
3937                 if (flush_failure) flush();
3938 #ifdef JP
3939                 msg_print("¤¦¤Þ¤¯»ÏÆ°¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Ê¤«¤Ã¤¿¡£");
3940 #else
3941                 msg_print("You failed to activate it properly.");
3942 #endif
3943
3944                 sound(SOUND_FAIL);
3945                 return;
3946         }
3947
3948         /* Check the recharge */
3949         if (o_ptr->timeout)
3950         {
3951 #ifdef JP
3952                 msg_print("¤½¤ì¤ÏÈù¤«¤Ë²»¤òΩ¤Æ¡¢µ±¤­¡¢¾Ã¤¨¤¿...");
3953 #else
3954                 msg_print("It whines, glows and fades...");
3955 #endif
3956
3957                 return;
3958         }
3959
3960
3961         /* Activate the artifact */
3962 #ifdef JP
3963         msg_print("»ÏÆ°¤µ¤»¤¿...");
3964 #else
3965         msg_print("You activate it...");
3966 #endif
3967
3968
3969         /* Sound */
3970         sound(SOUND_ZAP);
3971
3972
3973         if (o_ptr->art_name && o_ptr->xtra2)
3974         {
3975                 (void)activate_random_artifact(o_ptr);
3976
3977                 /* Window stuff */
3978                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
3979
3980                 /* Success */
3981                 return;
3982         }
3983
3984         /* Artifacts */
3985         else if (o_ptr->name1)
3986         {
3987                 /* Choose effect */
3988                 switch (o_ptr->name1)
3989                 {
3990                         case ART_GALADRIEL:
3991                         {
3992 #ifdef JP
3993                                 msg_print("ààÎÜÉÓ¤«¤éÀ¡¤ó¤À¸÷¤¬¤¢¤Õ¤ì½Ð¤¿...");
3994 #else
3995                                 msg_print("The phial wells with clear light...");
3996 #endif
3997
3998                                 lite_area(damroll(2, 15), 3);
3999                                 o_ptr->timeout = rand_int(10) + 10;
4000                                 break;
4001                         }
4002
4003                         case ART_ELENDIL:
4004                         {
4005 #ifdef JP
4006                                 msg_print("À±¤¬âÁ¤·¤¯µ±¤¤¤¿...");
4007 #else
4008                                 msg_print("The star shines brightly...");
4009 #endif
4010
4011                                 map_area(DETECT_RAD_MAP);
4012                                 lite_area(damroll(2, 15), 3);
4013                                 o_ptr->timeout = rand_int(50) + 50;
4014                                 break;
4015                         }
4016
4017                         case ART_THRAIN:
4018                         {
4019 #ifdef JP
4020 msg_print("¤½¤ÎÊõÀФÏÀÖ¤¯ÌÀ¤ë¤¯¸÷¤Ã¤¿¡ª");
4021 #else
4022                                 msg_print("The Jewel flashes bright red!");
4023 #endif
4024
4025                                 chg_virtue(V_KNOWLEDGE, 1);
4026                                 chg_virtue(V_ENLIGHTEN, 1);
4027                                 wiz_lite(FALSE, FALSE);
4028 #ifdef JP
4029 msg_print("¤½¤ÎÊõÀФϤ¢¤Ê¤¿¤ÎÂÎÎϤòÃ¥¤Ã¤¿...");
4030 take_hit(DAMAGE_LOSELIFE, damroll(3,8), "¿³È½¤ÎÊõÀÐ", -1);
4031 #else
4032                                 msg_print("The Jewel drains your vitality...");
4033                                 take_hit(DAMAGE_LOSELIFE, damroll(3, 8), "the Jewel of Judgement", -1);
4034 #endif
4035
4036                                 (void)detect_traps(DETECT_RAD_DEFAULT);
4037                                 (void)detect_doors(DETECT_RAD_DEFAULT);
4038                                 (void)detect_stairs(DETECT_RAD_DEFAULT);
4039
4040 #ifdef JP
4041 if (get_check("µ¢´Ô¤ÎÎϤò»È¤¤¤Þ¤¹¤«¡©"))
4042 #else
4043                                 if (get_check("Activate recall? "))
4044 #endif
4045
4046                                 {
4047                                         (void)word_of_recall();
4048                                 }
4049
4050                                 o_ptr->timeout = rand_int(20) + 20;
4051                                 break;
4052                         }
4053
4054                         case ART_CARLAMMAS:
4055                         {
4056 #ifdef JP
4057                                 msg_print("¥¢¥ß¥å¥ì¥Ã¥È¤«¤é±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
4058 #else
4059                                 msg_print("The amulet lets out a shrill wail...");
4060 #endif
4061
4062                                 k = 3 * p_ptr->lev;
4063                                 (void)set_protevil(randint(25) + k, FALSE);
4064                                 o_ptr->timeout = rand_int(225) + 225;
4065                                 break;
4066                         }
4067
4068                         case ART_INGWE:
4069                         {
4070 #ifdef JP
4071                                 msg_print("¥¢¥ß¥å¥ì¥Ã¥È¤ÏÊÕ¤ê¤òÁ±¤Î¥ª¡¼¥é¤ÇËþ¤¿¤·¤¿...");
4072 #else
4073                                 msg_print("The amulet floods the area with goodness...");
4074 #endif
4075
4076                                 dispel_evil(p_ptr->lev * 5);
4077                                 o_ptr->timeout = rand_int(200) + 200;
4078                                 break;
4079                         }
4080
4081                         case ART_YATA:
4082                         {
4083 #ifdef JP
4084                                 msg_print("¶À¤ÏÊÕ¤ê¤òÁ±¤Î¥ª¡¼¥é¤ÇËþ¤¿¤·¤¿...");
4085 #else
4086                                 msg_print("The mirror floods the area with goodness...");
4087 #endif
4088
4089                                 dispel_evil(p_ptr->lev * 5);
4090                                 o_ptr->timeout = rand_int(200) + 200;
4091                                 break;
4092                         }
4093
4094                         case ART_BARAHIR:
4095                         {
4096 #ifdef JP
4097 msg_print("¤¢¤Ê¤¿¤Ï¥Õ¥é¥­¥¢¤ËŨ¤òÄù¤á»¦¤¹¤è¤¦Ì¿¤¸¤¿¡£");
4098 #else
4099                                 msg_print("You order Frakir to strangle your opponent.");
4100 #endif
4101
4102                                 if (!get_aim_dir(&dir)) return;
4103                                 if (drain_life(dir, 100))
4104                                 o_ptr->timeout = rand_int(100) + 100;
4105                                 break;
4106                         }
4107
4108                         case ART_TULKAS:
4109                         {
4110 #ifdef JP
4111                                 msg_print("»ØÎؤÏÌÀ¤ë¤¯µ±¤¤¤¿...");
4112 #else
4113                                 msg_print("The ring glows brightly...");
4114 #endif
4115
4116                                 (void)set_fast(randint(75) + 75, FALSE);
4117                                 o_ptr->timeout = rand_int(150) + 150;
4118                                 break;
4119                         }
4120
4121                         case ART_NARYA:
4122                         {
4123 #ifdef JP
4124                                 msg_print("»ØÎؤϿ¼¹È¤Ëµ±¤¤¤¿...");
4125 #else
4126                                 msg_print("The ring glows deep red...");
4127 #endif
4128
4129                                 if (!get_aim_dir(&dir)) return;
4130                                 fire_ball(GF_FIRE, dir, 300, 3);
4131                                 o_ptr->timeout = rand_int(225) + 225;
4132                                 break;
4133                         }
4134
4135                         case ART_NENYA:
4136                         {
4137 #ifdef JP
4138                                 msg_print("»ØÎؤÏÇò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4139 #else
4140                                 msg_print("The ring glows bright white...");
4141 #endif
4142
4143                                 if (!get_aim_dir(&dir)) return;
4144                                 fire_ball(GF_COLD, dir, 400, 3);
4145                                 o_ptr->timeout = rand_int(325) + 325;
4146                                 break;
4147                         }
4148
4149                         case ART_VILYA:
4150                         case ART_GOURYU:
4151                         {
4152 #ifdef JP
4153                                 msg_print("»ØÎؤϿ¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4154 #else
4155                                 msg_print("The ring glows deep blue...");
4156 #endif
4157
4158                                 if (!get_aim_dir(&dir)) return;
4159                                 fire_ball(GF_ELEC, dir, 500, 3);
4160                                 o_ptr->timeout = rand_int(425) + 425;
4161                                 break;
4162                         }
4163
4164                         case ART_POWER:
4165                         case ART_AHO:
4166                         {
4167 #ifdef JP
4168                                 msg_print("»ØÎؤϼ¿¹õ¤Ëµ±¤¤¤¿...");
4169 #else
4170                                 msg_print("The ring glows intensely black...");
4171 #endif
4172
4173                                 if (!get_aim_dir(&dir)) return;
4174                                 ring_of_power(dir);
4175                                 o_ptr->timeout = rand_int(450) + 450;
4176                                 break;
4177                         }
4178
4179                         case ART_RAZORBACK:
4180                         {
4181                                 int num = damroll(5, 3);
4182                                 int y, x;
4183                                 int attempts;
4184
4185 #ifdef JP
4186                                 msg_print("³»¤¬°ðºÊ¤Çʤ¤ï¤ì¤¿...");
4187 #else
4188                                 msg_print("Your armor is surrounded by lightning...");
4189 #endif
4190
4191
4192                                 for (k = 0; k < num; k++)
4193                                 {
4194                 attempts = 1000;
4195
4196                                         while(attempts--)
4197                                         {
4198                                                 scatter(&y, &x, py, px, 4, 0);
4199
4200                                                 if (!cave_floor_bold(y, x)) continue;
4201
4202                                                 if ((y != py) || (x != px)) break;
4203                                         }
4204
4205                                         project(0, 3, y, x, 150, GF_ELEC,
4206                                                           (PROJECT_THRU | PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
4207                                 }
4208
4209                                 o_ptr->timeout = 1000;
4210                                 break;
4211                         }
4212
4213                         case ART_BLADETURNER:
4214                         {
4215                                 if (!get_aim_dir(&dir)) return;
4216 #ifdef JP
4217                                 msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
4218 #else
4219                                 msg_print("You breathe the elements.");
4220 #endif
4221
4222                                 fire_ball(GF_MISSILE, dir, 300, 4);
4223 #ifdef JP
4224                                 msg_print("¥¢¡¼¥Þ¡¼¤¬ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤¿...");
4225 #else
4226                                 msg_print("Your armor glows many colours...");
4227 #endif
4228
4229                                 (void)set_afraid(0);
4230                                 (void)set_hero(randint(50) + 50, FALSE);
4231                                 (void)hp_player(10);
4232                                 (void)set_blessed(randint(50) + 50, FALSE);
4233                                 (void)set_oppose_acid(randint(50) + 50, FALSE);
4234                                 (void)set_oppose_elec(randint(50) + 50, FALSE);
4235                                 (void)set_oppose_fire(randint(50) + 50, FALSE);
4236                                 (void)set_oppose_cold(randint(50) + 50, FALSE);
4237                                 (void)set_oppose_pois(randint(50) + 50, FALSE);
4238                                 o_ptr->timeout = 400;
4239                                 break;
4240                         }
4241
4242                         case ART_SOULKEEPER:
4243                         {
4244 #ifdef JP
4245                                 msg_print("¥¢¡¼¥Þ¡¼¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4246                                 msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬¤è¤¤...");
4247 #else
4248                                 msg_print("Your armor glows a bright white...");
4249                                 msg_print("You feel much better...");
4250 #endif
4251
4252                                 (void)hp_player(1000);
4253                                 (void)set_cut(0);
4254                                 o_ptr->timeout = 888;
4255                                 break;
4256                         }
4257
4258                         case ART_BELEGENNON:
4259                         {
4260 #ifdef JP
4261 msg_print("Å·¹ñ¤Î²Î¤¬Ê¹¤³¤¨¤ë...");
4262 #else
4263                                 msg_print("A heavenly choir sings...");
4264 #endif
4265
4266                                 (void)set_poisoned(0);
4267                                 (void)set_cut(0);
4268                                 (void)set_stun(0);
4269                                 (void)set_confused(0);
4270                                 (void)set_blind(0);
4271                                 (void)set_hero(randint(25) + 25, FALSE);
4272                                 (void)hp_player(777);
4273                                 o_ptr->timeout = 300;
4274                                 break;
4275                         }
4276
4277                         case ART_CELEBORN:
4278                         {
4279 #ifdef JP
4280                                 msg_print("¥¢¡¼¥Þ¡¼¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4281 #else
4282                                 msg_print("Your armor glows deep blue...");
4283 #endif
4284
4285                                 (void)symbol_genocide(200, TRUE);
4286                                 o_ptr->timeout = 500;
4287                                 break;
4288                         }
4289
4290                         case ART_CASPANION:
4291                         {
4292 #ifdef JP
4293                                 msg_print("¥¢¡¼¥Þ¡¼¤¬ÀÖ¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4294 #else
4295                                 msg_print("Your armor glows bright red...");
4296 #endif
4297
4298                                 destroy_doors_touch();
4299                                 o_ptr->timeout = 10;
4300                                 break;
4301                         }
4302
4303                         case ART_DOR:
4304                         case ART_TERROR:
4305                         case ART_STONEMASK:
4306                         {
4307                                 turn_monsters(40 + p_ptr->lev);
4308                                 o_ptr->timeout = 3 * (p_ptr->lev + 10);
4309
4310                                 break;
4311                         }
4312
4313                         case ART_HOLHENNETH:
4314                         {
4315 #ifdef JP
4316                                 msg_print("¥Ø¥ë¥á¥Ã¥È¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4317                                 msg_print("¿´¤Ë¥¤¥á¡¼¥¸¤¬É⤫¤ó¤Ç¤­¤¿...");
4318 #else
4319                                 msg_print("Your helm glows bright white...");
4320                                 msg_print("An image forms in your mind...");
4321 #endif
4322
4323                                 detect_all(DETECT_RAD_DEFAULT);
4324                                 o_ptr->timeout = rand_int(55) + 55;
4325                                 break;
4326                         }
4327
4328                         case ART_GONDOR:
4329                         {
4330 #ifdef JP
4331                                 msg_print("²¦´§¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4332                                 msg_print("ÂÎÆâ¤ËÃȤ«¤¤¸ÝÆ°¤¬´¶¤¸¤é¤ì¤ë...");
4333 #else
4334                                 msg_print("Your crown glows deep blue...");
4335                                 msg_print("You feel a warm tingling inside...");
4336 #endif
4337
4338                                 (void)hp_player(700);
4339                                 (void)set_cut(0);
4340                                 o_ptr->timeout = 250;
4341                                 break;
4342                         }
4343
4344                         case ART_COLLUIN:
4345                         case ART_SEIRYU:
4346                         {
4347 #ifdef JP
4348                                 msg_format("%s¤¬ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤¿...", o_ptr->name1 == ART_COLLUIN ? "¥¯¥í¡¼¥¯" : "³»");
4349 #else
4350                                 msg_format("Your cloak glows many colours...");
4351 #endif
4352
4353                                 (void)set_oppose_acid(randint(20) + 20, FALSE);
4354                                 (void)set_oppose_elec(randint(20) + 20, FALSE);
4355                                 (void)set_oppose_fire(randint(20) + 20, FALSE);
4356                                 (void)set_oppose_cold(randint(20) + 20, FALSE);
4357                                 (void)set_oppose_pois(randint(20) + 20, FALSE);
4358                                 o_ptr->timeout = 111;
4359                                 break;
4360                         }
4361
4362                         case ART_HOLCOLLETH:
4363                         {
4364 #ifdef JP
4365                                 msg_print("¥¯¥í¡¼¥¯¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4366 #else
4367                                 msg_print("Your cloak glows deep blue...");
4368 #endif
4369
4370                                 sleep_monsters_touch();
4371                                 o_ptr->timeout = 55;
4372                                 break;
4373                         }
4374
4375                         case ART_THINGOL:
4376                         {
4377 #ifdef JP
4378                                 msg_print("¥¯¥í¡¼¥¯¤¬²«¿§¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4379 #else
4380                                 msg_print("Your cloak glows bright yellow...");
4381 #endif
4382
4383                                 recharge(130);
4384                                 o_ptr->timeout = 70;
4385                                 break;
4386                         }
4387
4388                         case ART_COLANNON:
4389                         {
4390 #ifdef JP
4391                                 msg_print("¥¯¥í¡¼¥¯¤¬ÊÕ¤ê¤Î¶õ´Ö¤ò¤æ¤¬¤Þ¤»¤¿...");
4392 #else
4393                                 msg_print("Your cloak twists space around you...");
4394 #endif
4395
4396                                 teleport_player(100);
4397                                 o_ptr->timeout = 45;
4398                                 break;
4399                         }
4400
4401                         case ART_LUTHIEN:
4402                         {
4403 #ifdef JP
4404                                 msg_print("¥¯¥í¡¼¥¯¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
4405 #else
4406                                 msg_print("Your cloak glows a deep red...");
4407 #endif
4408
4409                                 restore_level();
4410                                 o_ptr->timeout = 450;
4411                                 break;
4412                         }
4413
4414                         case ART_CAMMITHRIM:
4415                         {
4416 #ifdef JP
4417                                 msg_print("¥°¥í¡¼¥Ö¤¬âÁ¤·¤¤¤¯¤é¤¤¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
4418 #else
4419                                 msg_print("Your gloves glow extremely brightly...");
4420 #endif
4421
4422                                 if (!get_aim_dir(&dir)) return;
4423                                 fire_bolt(GF_MISSILE, dir, damroll(2, 6));
4424                                 o_ptr->timeout = 2;
4425                                 break;
4426                         }
4427
4428                         case ART_PAURHACH:
4429                         {
4430 #ifdef JP
4431                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬±ê¤Ëʤ¤ï¤ì¤¿...");
4432 #else
4433                                 msg_print("Your gauntlets are covered in fire...");
4434 #endif
4435
4436                                 if (!get_aim_dir(&dir)) return;
4437                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
4438                                 o_ptr->timeout = rand_int(8) + 8;
4439                                 break;
4440                         }
4441
4442                         case ART_PAURNIMMEN:
4443                         {
4444 #ifdef JP
4445                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4446 #else
4447                                 msg_print("Your gauntlets are covered in frost...");
4448 #endif
4449
4450                                 if (!get_aim_dir(&dir)) return;
4451                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
4452                                 o_ptr->timeout = rand_int(7) + 7;
4453                                 break;
4454                         }
4455
4456                         case ART_PAURAEGEN:
4457                         {
4458 #ifdef JP
4459                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬²Ð²Ö¤Ëʤ¤ï¤ì¤¿...");
4460 #else
4461                                 msg_print("Your gauntlets are covered in sparks...");
4462 #endif
4463
4464                                 if (!get_aim_dir(&dir)) return;
4465                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
4466                                 o_ptr->timeout = rand_int(5) + 5;
4467                                 break;
4468                         }
4469
4470                         case ART_PAURNEN:
4471                         {
4472 #ifdef JP
4473                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬»À¤Ëʤ¤ï¤ì¤¿...");
4474 #else
4475                                 msg_print("Your gauntlets are covered in acid...");
4476 #endif
4477
4478                                 if (!get_aim_dir(&dir)) return;
4479                                 fire_bolt(GF_ACID, dir, damroll(5, 8));
4480                                 o_ptr->timeout = rand_int(6) + 6;
4481                                 break;
4482                         }
4483
4484                         case ART_FINGOLFIN:
4485                         {
4486 #ifdef JP
4487                                 msg_print("¥»¥¹¥¿¥¹¤ËËâË¡¤Î¥È¥²¤¬¸½¤ì¤¿...");
4488 #else
4489                                 msg_print("Your cesti grows magical spikes...");
4490 #endif
4491
4492                                 if (!get_aim_dir(&dir)) return;
4493                                 fire_bolt(GF_ARROW, dir, 150);
4494                                 o_ptr->timeout = rand_int(90) + 90;
4495                                 break;
4496                         }
4497
4498                         case ART_FEANOR:
4499                         {
4500 #ifdef JP
4501                                 msg_print("¥Ö¡¼¥Ä¤¬¥°¥ê¡¼¥ó¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
4502 #else
4503                                 msg_print("Your boots glow bright green...");
4504 #endif
4505
4506                                 (void)set_fast(randint(20) + 20, FALSE);
4507                                 o_ptr->timeout = 200;
4508                                 break;
4509                         }
4510
4511                         case ART_DAL:
4512                         {
4513 #ifdef JP
4514                                 msg_print("¥Ö¡¼¥Ä¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4515 #else
4516                                 msg_print("Your boots glow deep blue...");
4517 #endif
4518
4519                                 (void)set_afraid(0);
4520                                 (void)set_poisoned(0);
4521                                 o_ptr->timeout = 5;
4522                                 break;
4523                         }
4524
4525                         case ART_NARTHANC:
4526                         {
4527 #ifdef JP
4528                                 msg_print("¥À¥¬¡¼¤¬±ê¤Ëʤ¤ï¤ì¤¿...");
4529 #else
4530                                 msg_print("Your dagger is covered in fire...");
4531 #endif
4532
4533                                 if (!get_aim_dir(&dir)) return;
4534                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
4535                                 o_ptr->timeout = rand_int(8) + 8;
4536                                 break;
4537                         }
4538
4539                         case ART_NIMTHANC:
4540                         {
4541 #ifdef JP
4542                                 msg_print("¥À¥¬¡¼¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4543 #else
4544                                 msg_print("Your dagger is covered in frost...");
4545 #endif
4546
4547                                 if (!get_aim_dir(&dir)) return;
4548                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
4549                                 o_ptr->timeout = rand_int(7) + 7;
4550                                 break;
4551                         }
4552
4553                         case ART_DETHANC:
4554                         {
4555 #ifdef JP
4556                                 msg_print("¥À¥¬¡¼¤¬²Ð²Ö¤Ëʤ¤ï¤ì¤¿...");
4557 #else
4558                                 msg_print("Your dagger is covered in sparks...");
4559 #endif
4560
4561                                 if (!get_aim_dir(&dir)) return;
4562                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
4563                                 o_ptr->timeout = rand_int(5) + 5;
4564                                 break;
4565                         }
4566
4567                         case ART_RILIA:
4568                         {
4569 #ifdef JP
4570                                 msg_print("¥À¥¬¡¼¤¬¿¼¤¤Îп§¤Ë¸ÝÆ°¤·¤Æ¤¤¤ë...");
4571 #else
4572                                 msg_print("Your dagger throbs deep green...");
4573 #endif
4574
4575                                 if (!get_aim_dir(&dir)) return;
4576                                 fire_ball(GF_POIS, dir, 12, 3);
4577                                 o_ptr->timeout = rand_int(4) + 4;
4578                                 break;
4579                         }
4580
4581                         case ART_NUMAHOKO:
4582                         {
4583 #ifdef JP
4584                                 msg_print("Ì·¤¬¿¼¤¤ÀÄ¿§¤Ë¸ÝÆ°¤·¤Æ¤¤¤ë...");
4585 #else
4586                                 msg_print("Your dagger throbs deep blue...");
4587 #endif
4588
4589                                 if (!get_aim_dir(&dir)) return;
4590                                 fire_ball(GF_WATER, dir, 200, 3);
4591                                 o_ptr->timeout = 250;
4592                                 break;
4593                         }
4594
4595                         case ART_BELANGIL:
4596                         {
4597 #ifdef JP
4598                                 msg_print("¥À¥¬¡¼¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4599 #else
4600                                 msg_print("Your dagger is covered in frost...");
4601 #endif
4602
4603                                 if (!get_aim_dir(&dir)) return;
4604                                 fire_ball(GF_COLD, dir, 48, 2);
4605                                 o_ptr->timeout = rand_int(5) + 5;
4606                                 break;
4607                         }
4608
4609                         case ART_KUSANAGI:
4610                         case ART_ANGUIREL:
4611                         {
4612                                 switch (randint(13))
4613                                 {
4614                                 case 1: case 2: case 3: case 4: case 5:
4615                                         teleport_player(10);
4616                                         break;
4617                                 case 6: case 7: case 8: case 9: case 10:
4618                                         teleport_player(222);
4619                                         break;
4620                                 case 11: case 12:
4621                                         (void)stair_creation();
4622                                         break;
4623                                 default:
4624 #ifdef JP
4625 if (get_check("¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
4626 #else
4627                                         if (get_check("Leave this level? "))
4628 #endif
4629
4630                                         {
4631                                                 if (autosave_l) do_cmd_save_game(TRUE);
4632
4633                                                 /* Leaving */
4634                                                 p_ptr->leaving = TRUE;
4635                                         }
4636                                 }
4637                                 o_ptr->timeout = 35;
4638                                 break;
4639                         }
4640
4641                         case ART_KAMUI:
4642                         {
4643                                 teleport_player(222);
4644                                 o_ptr->timeout = 25;
4645                                 break;
4646                         }
4647
4648                         case ART_RINGIL:
4649                         {
4650 #ifdef JP
4651                                 msg_print("¥½¡¼¥É¤¬ÀĤ¯·ã¤·¤¯µ±¤¤¤¿...");
4652 #else
4653                                 msg_print("Your sword glows an intense blue...");
4654 #endif
4655
4656                                 if (!get_aim_dir(&dir)) return;
4657                                 fire_ball(GF_COLD, dir, 100, 2);
4658                                 o_ptr->timeout = 200;
4659                                 break;
4660                         }
4661
4662                         case ART_DAWN:
4663                         {
4664 #ifdef JP
4665 msg_print("¶Ç¤Î»ÕÃĤò¾¤´­¤·¤¿¡£");
4666 #else
4667                                 msg_print("You summon the Legion of the Dawn.");
4668 #endif
4669
4670                                 (void)summon_specific(-1, py, px, dun_level, SUMMON_DAWN, TRUE, TRUE, TRUE, FALSE, FALSE);
4671                                 o_ptr->timeout = 500 + randint(500);
4672                                 break;
4673                         }
4674
4675                         case ART_ANDURIL:
4676                         {
4677 #ifdef JP
4678                                 msg_print("¥½¡¼¥É¤¬ÀÖ¤¯·ã¤·¤¯µ±¤¤¤¿...");
4679 #else
4680                                 msg_print("Your sword glows an intense red...");
4681 #endif
4682
4683                                 if (!get_aim_dir(&dir)) return;
4684                                 fire_ball(GF_FIRE, dir, 72, 2);
4685                                 o_ptr->timeout = 400;
4686                                 break;
4687                         }
4688
4689                         case ART_THEODEN:
4690                         {
4691 #ifdef JP
4692                                  msg_print("¥¢¥Ã¥¯¥¹¤Î¿Ï¤¬¹õ¤¯µ±¤¤¤¿...");
4693 #else
4694                                 msg_print("Your axe blade glows black...");
4695 #endif
4696
4697                                 if (!get_aim_dir(&dir)) return;
4698                                 drain_life(dir, 120);
4699                                 o_ptr->timeout = 400;
4700                                 break;
4701                         }
4702
4703                         case ART_RUNESPEAR:
4704                         {
4705 #ifdef JP
4706 msg_print("¤¢¤Ê¤¿¤ÎÁä¤ÏÅŵ¤¤Ç¥¹¥Ñ¡¼¥¯¤·¤Æ¤¤¤ë...");
4707 #else
4708                                 msg_print("Your spear crackles with electricity...");
4709 #endif
4710
4711                                 if (!get_aim_dir(&dir)) return;
4712                                 fire_ball(GF_ELEC, dir, 100, 3);
4713                                 o_ptr->timeout = 200;
4714                                 break;
4715                         }
4716
4717                         case ART_AEGLOS:
4718                         {
4719 #ifdef JP
4720                                 msg_print("¥¹¥Ô¥¢¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4721 #else
4722                                 msg_print("Your spear glows a bright white...");
4723 #endif
4724
4725                                 if (!get_aim_dir(&dir)) return;
4726                                 fire_ball(GF_COLD, dir, 100, 3);
4727                                 o_ptr->timeout = 200;
4728                                 break;
4729                         }
4730
4731                         case ART_OROME:
4732                         {
4733 #ifdef JP
4734                                 msg_print("¥¹¥Ô¥¢¤¬¸ÝÆ°¤·¤¿...");
4735 #else
4736                                 msg_print("Your spear pulsates...");
4737 #endif
4738
4739                                 if (!get_aim_dir(&dir)) return;
4740                                 wall_to_mud(dir);
4741                                 o_ptr->timeout = 5;
4742                                 break;
4743                         }
4744
4745                         case ART_NAIN:
4746                         {
4747 #ifdef JP
4748                                 msg_print("¤Ä¤ë¤Ï¤·¤¬¸ÝÆ°¤·¤¿...");
4749 #else
4750                                 msg_print("Your mattock pulsates...");
4751 #endif
4752
4753                                 if (!get_aim_dir(&dir)) return;
4754                                 wall_to_mud(dir);
4755                                 o_ptr->timeout = 2;
4756                                 break;
4757                         }
4758
4759                         case ART_EONWE:
4760                         {
4761 #ifdef JP
4762                                 msg_print("¥¢¥Ã¥¯¥¹¤«¤é¤Ò¤É¤¯±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
4763 #else
4764                                 msg_print("Your axe lets out a long, shrill note...");
4765 #endif
4766
4767                                 (void)mass_genocide(200, TRUE);
4768                                 o_ptr->timeout = 1000;
4769                                 break;
4770                         }
4771
4772                         case ART_LOTHARANG:
4773                         {
4774 #ifdef JP
4775                                 msg_print("¥Ð¥È¥ë¡¦¥¢¥Ã¥¯¥¹¤¬¿¼»ç¤Î¸÷¤òÊü¼Í¤·¤¿...");
4776 #else
4777                                 msg_print("Your battle axe radiates deep purple...");
4778 #endif
4779
4780                                 hp_player(damroll(4, 8));
4781                                 (void)set_cut((p_ptr->cut / 2) - 50);
4782                                 o_ptr->timeout = rand_int(3) + 3;
4783                                 break;
4784                         }
4785
4786                         case ART_ULMO:
4787                         {
4788 #ifdef JP
4789                                 msg_print("¥È¥é¥¤¥Ç¥ó¥È¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
4790 #else
4791                                 msg_print("Your trident glows deep red...");
4792 #endif
4793
4794                                 if (!get_aim_dir(&dir)) return;
4795                                 teleport_monster(dir);
4796                                 o_ptr->timeout = 150;
4797                                 break;
4798                         }
4799
4800                         case ART_AVAVIR:
4801                         {
4802 #ifdef JP
4803                                 msg_print("Âç³ù¤¬½À¤é¤«¤¯Çò¤¯µ±¤¤¤¿...");
4804 #else
4805                                 msg_print("Your scythe glows soft white...");
4806 #endif
4807                                 if (!word_of_recall()) return;
4808                                 o_ptr->timeout = 200;
4809                                 break;
4810                         }
4811
4812                         case ART_MAGATAMA:
4813                         {
4814 #ifdef JP
4815                                 msg_print("¸û¶Ì¤¬½À¤é¤«¤¯Çò¤¯µ±¤¤¤¿...");
4816 #else
4817                                 msg_print("Your scythe glows soft white...");
4818 #endif
4819                                 if (!word_of_recall()) return;
4820                                 o_ptr->timeout = 200;
4821                                 break;
4822                         }
4823
4824                         case ART_TOTILA:
4825                         {
4826 #ifdef JP
4827                                 msg_print("¥Õ¥ì¥¤¥ë¤¬ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤¿...");
4828 #else
4829                                 msg_print("Your flail glows in scintillating colours...");
4830 #endif
4831
4832                                 if (!get_aim_dir(&dir)) return;
4833                                 confuse_monster(dir, 20);
4834                                 o_ptr->timeout = 15;
4835                                 break;
4836                         }
4837
4838                         case ART_FIRESTAR:
4839                         {
4840 #ifdef JP
4841                                 msg_print("¥â¡¼¥Ë¥ó¥°¥¹¥¿¡¼¤«¤é±ê¤¬¿á¤­½Ð¤·¤¿...");
4842 #else
4843                                 msg_print("Your morning star rages in fire...");
4844 #endif
4845
4846                                 if (!get_aim_dir(&dir)) return;
4847                                 fire_ball(GF_FIRE, dir, 72, 3);
4848                                 o_ptr->timeout = 100;
4849                                 break;
4850                         }
4851
4852                         case ART_GOTHMOG:
4853                         {
4854 #ifdef JP
4855                                 msg_print("¥à¥Á¤¬¿¼¤¤ÀÖ¿§¤Ëµ±¤¤¤¿...");
4856 #else
4857                                 msg_print("Your whip glows deep red...");
4858 #endif
4859
4860                                 if (!get_aim_dir(&dir)) return;
4861                                 fire_ball(GF_FIRE, dir, 120, 3);
4862                                 o_ptr->timeout = 15;
4863                                 break;
4864                         }
4865
4866                         case ART_TARATOL:
4867                         {
4868 #ifdef JP
4869                                 msg_print("¥á¥¤¥¹¤¬¥°¥ê¡¼¥ó¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
4870 #else
4871                                 msg_print("Your mace glows bright green...");
4872 #endif
4873
4874                                 (void)set_fast(randint(20) + 20, FALSE);
4875                                 o_ptr->timeout = rand_int(100) + 100;
4876                                 break;
4877                         }
4878
4879                         case ART_ERIRIL:
4880                         {
4881 #ifdef JP
4882                                 msg_print("¥¯¥©¡¼¥¿¡¼¥¹¥¿¥Ã¥Õ¤¬²«¿§¤¯µ±¤¤¤¿...");
4883 #else
4884                                 msg_print("Your quarterstaff glows yellow...");
4885 #endif
4886
4887                                 if (!ident_spell(FALSE)) return;
4888                                 o_ptr->timeout = 10;
4889                                 break;
4890                         }
4891
4892                         case ART_OLORIN:
4893                         {
4894 #ifdef JP
4895                                 msg_print("¾ó¤¬ÌÀ¤ë¤¯µ±¤¤¤¿...");
4896 #else
4897                                 msg_print("Your quarterstaff glows brightly...");
4898 #endif
4899
4900                                 detect_all(DETECT_RAD_DEFAULT);
4901                                 probing();
4902                                 identify_fully(FALSE);
4903                                 o_ptr->timeout = 1000;
4904                                 break;
4905                         }
4906
4907                         case ART_TURMIL:
4908                         {
4909 #ifdef JP
4910                                 msg_print("¥Ï¥ó¥Þ¡¼¤¬Çò¤¯µ±¤¤¤¿...");
4911 #else
4912                                 msg_print("Your hammer glows white...");
4913 #endif
4914
4915                                 if (!get_aim_dir(&dir)) return;
4916                                 drain_life(dir, 90);
4917                                 o_ptr->timeout = 70;
4918                                 break;
4919                         }
4920
4921                         case ART_BRAND:
4922                         {
4923 #ifdef JP
4924                                 msg_print("¥¯¥í¥¹¥Ü¥¦¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
4925 #else
4926                                 msg_print("Your crossbow glows deep red...");
4927 #endif
4928
4929                                 (void)brand_bolts();
4930                                 o_ptr->timeout = 999;
4931                                 break;
4932                         }
4933                         case ART_CRIMSON:
4934                         {
4935                                 int num = 1;
4936                                 int i;
4937                                 int flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_NO_REF;
4938                                 int tx, ty;
4939 #ifdef JP
4940                                 msg_print("¤»¤Ã¤«¤¯¤À¤«¤é¡Ø¥¯¥ê¥à¥¾¥ó¡Ù¤ò¤Ö¤Ã¤Ñ¤Ê¤¹¤¼¡ª");
4941 #else
4942                                 msg_print("I'll fire CRIMSON! SEKKAKUDAKARA!");
4943 #endif
4944
4945                                 if (!get_aim_dir(&dir)) return;
4946
4947                                 /* Use the given direction */
4948                                 tx = px + 99 * ddx[dir];
4949                                 ty = py + 99 * ddy[dir];
4950
4951                                 /* Hack -- Use an actual "target" */
4952                                 if ((dir == 5) && target_okay())
4953                                 {
4954                                         tx = target_col;
4955                                         ty = target_row;
4956                                 }
4957
4958                                 if (p_ptr->pclass == CLASS_ARCHER)
4959                                 {
4960                                         /* Extra shot at level 10 */
4961                                         if (p_ptr->lev >= 10) num++;
4962
4963                                         /* Extra shot at level 30 */
4964                                         if (p_ptr->lev >= 30) num++;
4965
4966                                         /* Extra shot at level 45 */
4967                                         if (p_ptr->lev >= 45) num++;
4968                                 }
4969
4970                                 for (i = 0; i < num; i++)
4971                                         project(0, p_ptr->lev/20+1, ty, tx, p_ptr->lev*6, GF_ROCKET, flg, -1);
4972                                 o_ptr->timeout = 15;
4973                                 break;
4974                         }
4975                         case ART_PALANTIR:
4976                         {
4977                                 monster_type *m_ptr;
4978                                 monster_race *r_ptr;
4979                                 int i;
4980
4981 #ifdef JP
4982                                 msg_print("´ñ̯¤Ê¾ì½ê¤¬Æ¬¤ÎÃæ¤ËÉ⤫¤ó¤À¡¥¡¥¡¥");
4983 #else
4984                                 msg_print("Some strange places show up in your mind. And you see ...");
4985 #endif
4986
4987                                 /* Process the monsters (backwards) */
4988                                 for (i = m_max - 1; i >= 1; i--)
4989                                 {
4990                                         /* Access the monster */
4991                                         m_ptr = &m_list[i];
4992
4993                                         /* Ignore "dead" monsters */
4994                                         if (!m_ptr->r_idx) continue;
4995
4996                                         r_ptr = &r_info[m_ptr->r_idx];
4997
4998                                         if(r_ptr->flags1 & RF1_UNIQUE)
4999                                         {
5000 #ifdef JP
5001                                                 msg_format("%s¡¥ ",r_name + r_ptr->name);
5002 #else
5003                                                 msg_format("%s. ",r_name + r_ptr->name);
5004 #endif
5005                                         }
5006                                 }
5007                                 o_ptr->timeout = 200;
5008                                 break;
5009                         }
5010
5011                         case ART_STONE_LORE:
5012                         {
5013 #ifdef JP
5014                                 msg_print("ÀФ¬±£¤µ¤ì¤¿ÈëÌ©¤ò¼Ì¤·½Ð¤·¤¿¡¥¡¥¡¥");
5015 #else
5016                                 msg_print("The stone reveals hidden mysteries...");
5017 #endif
5018                                 if (!ident_spell(FALSE)) return;
5019
5020                                 if (mp_ptr->spell_book)
5021                                 {
5022                                         /* Sufficient mana */
5023                                         if (20 <= p_ptr->csp)
5024                                         {
5025                                                 /* Use some mana */
5026                                                 p_ptr->csp -= 20;
5027                                         }
5028
5029                                         /* Over-exert the player */
5030                                         else
5031                                         {
5032                                                 int oops = 20 - p_ptr->csp;
5033
5034                                                 /* No mana left */
5035                                                 p_ptr->csp = 0;
5036                                                 p_ptr->csp_frac = 0;
5037
5038                                                 /* Message */
5039 #ifdef JP
5040                                                 msg_print("ÀФòÀ©¸æ¤Ç¤­¤Ê¤¤¡ª");
5041 #else
5042                                                 msg_print("You are too weak to control the stone!");
5043 #endif
5044
5045                                                 /* Hack -- Bypass free action */
5046                                                 (void)set_paralyzed(p_ptr->paralyzed +
5047                                                         randint(5 * oops + 1));
5048
5049                                                 /* Confusing. */
5050                                                 (void)set_confused(p_ptr->confused +
5051                                                         randint(5 * oops + 1));
5052                                         }
5053
5054                                         /* Redraw mana */
5055                                         p_ptr->redraw |= (PR_MANA);
5056                                 }
5057
5058 #ifdef JP
5059                                 take_hit(DAMAGE_LOSELIFE, damroll(1, 12), "´í¸±¤ÊÈëÌ©", -1);
5060 #else
5061                                 take_hit(DAMAGE_LOSELIFE, damroll(1, 12), "perilous secrets", -1);
5062 #endif
5063
5064                                 /* Confusing. */
5065                                 if (rand_int(5) == 0) (void)set_confused(p_ptr->confused +
5066                                         randint(10));
5067
5068                                 /* Exercise a little care... */
5069                                 if (rand_int(20) == 0)
5070 #ifdef JP
5071                                         take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "´í¸±¤ÊÈëÌ©", -1);
5072 #else
5073                                         take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "perilous secrets", -1);
5074 #endif
5075                                 o_ptr->timeout = 0;
5076                                 break;
5077                         }
5078
5079                         case ART_BOROMIR:
5080                         {
5081                                 msg_print("You wind a mighty blast; your enemies tremble!");
5082                                 (void)turn_monsters((3 * p_ptr->lev / 2) + 10);
5083                                 o_ptr->timeout = rand_int(40) + 40;
5084                                 break;
5085                         }
5086                         case ART_FARAMIR:
5087                         {
5088 #ifdef JP
5089                                 msg_print("¤¢¤Ê¤¿¤Ï³²Ãî¤ò°ìÁݤ·¤¿¡£");
5090 #else
5091                                 msg_print("You exterminate small life.");
5092 #endif
5093                                 (void)dispel_monsters(4);
5094                                 o_ptr->timeout = rand_int(55) + 55;
5095                                 break;
5096                         }
5097
5098                         case ART_HIMRING:
5099                         {
5100 #ifdef JP
5101                                 msg_print("Æߤ¤²»¤¬ÊÕ¤ê¤òÊñ¤ß¤³¤ó¤À¡£");
5102 #else
5103                                 msg_print("A shrill wailing sound surrounds you.");
5104 #endif
5105                                 (void)set_protevil(randint(25) + p_ptr->lev, FALSE);
5106                                 o_ptr->timeout = rand_int(200) + 200;
5107                                 break;
5108                         }
5109
5110                         case ART_ICANUS:
5111                         {
5112
5113 #ifdef JP
5114                                 msg_print("¥í¡¼¥Ö¤¬½ã¿è¤ÊËâÎϤǿ̤¨¤¿¡£");
5115 #else
5116                                 msg_print("The robe pulsates with raw mana...");
5117 #endif
5118                                 if (!get_aim_dir(&dir)) return;
5119                                 fire_bolt(GF_MANA, dir, 120);
5120                                 o_ptr->timeout = rand_int(120) + 120;
5121                                 break;
5122                         }
5123                         case ART_HURIN:
5124                         {
5125                                 (void)set_fast(randint(50) + 50, FALSE);
5126                                 hp_player(10);
5127                                 set_afraid(0);
5128                                 set_hero(randint(50) + 50, FALSE);
5129                                 o_ptr->timeout = rand_int(200) + 100;
5130                                 break;
5131                         }
5132                         case ART_GIL_GALAD:
5133                         {
5134 #ifdef JP
5135                                 msg_print("¥·¡¼¥ë¥É¤¬âÁ¤·¤¤¸÷¤Çµ±¤¤¤¿¡¥¡¥¡¥");
5136 #else
5137                                 msg_print("Your shield gleams with blinding light...");
5138 #endif
5139                                 fire_ball(GF_LITE, 0, 300, 6);
5140                                 confuse_monsters(3 * p_ptr->lev / 2);
5141                                 o_ptr->timeout = 250;
5142                                 break;
5143                         }
5144                         case ART_YENDOR:
5145                         {
5146 #ifdef JP
5147                                 msg_print("¥«¡¼¥É¤¬Çò¤¯µ±¤¤¤¿¡¥¡¥¡¥");
5148 #else
5149                                 msg_print("Your card gleams with blinding light...");
5150 #endif
5151                                 if (!recharge(1000)) return;
5152                                 o_ptr->timeout = 200;
5153                                 break;
5154                         }
5155                         case ART_MURAMASA:
5156                         {
5157                                 if (get_check("ËÜÅö¤Ë»È¤¤¤Þ¤¹¤«¡©"))
5158                                 {
5159 #ifdef JP
5160                                         msg_print("¼Àµ¤¬¿Ì¤¨¤¿¡¥¡¥¡¥");
5161 #else
5162                                         msg_print("The Muramasa pulsates...");
5163 #endif
5164                                         do_inc_stat(A_STR);
5165                                         if (one_in_(2))
5166                                         {
5167 #ifdef JP
5168                                                 msg_print("¼Àµ¤Ï²õ¤ì¤¿¡ª");
5169 #else
5170                                                 msg_print("The Muramasa is destroyed!");
5171 #endif
5172                                                 curse_weapon(TRUE, item);
5173                                         }
5174                                 }
5175                                 break;
5176                         }
5177                         case ART_FLY_STONE:
5178                         {
5179 #ifdef JP
5180                                 msg_print("ÀФ¬ÀÄÇò¤¯¸÷¤Ã¤¿¡¥¡¥¡¥");
5181 #else
5182                                 msg_print("Your stone glows pale...");
5183 #endif
5184
5185                                 if (!get_aim_dir(&dir)) return;
5186                                 fire_ball(GF_MANA, dir, 400, 4);
5187                                 o_ptr->timeout = rand_int(250) + 250;
5188                                 break;
5189                         }
5190                         case ART_TAIKOBO:
5191                         {
5192                                 int x, y;
5193
5194                                 if (!get_rep_dir2(&dir)) return;
5195                                 y = py+ddy[dir];
5196                                 x = px+ddx[dir];
5197                                 tsuri_dir = dir;
5198                                 if (!(cave[y][x].feat == FEAT_DEEP_WATER) && !(cave[y][x].feat == FEAT_SHAL_WATER))
5199                                 {
5200 #ifdef JP
5201                                         msg_print("¤½¤³¤ÏΦÃϤÀ¡£");
5202 #else
5203                                         msg_print("There is no fishing place.");
5204 #endif
5205                                         return;
5206                                 }
5207                                 else if (cave[y][x].m_idx)
5208                                 {
5209                                         char m_name[80];
5210                                         monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5211 #ifdef JP
5212                                         msg_format("%s¤¬¼ÙËâ¤À¡ª", m_name);
5213 #else
5214                                         msg_format("%^s is stand in your way.", m_name);
5215 #endif
5216                                         energy_use = 0;
5217                                         return;
5218                                 }
5219                                 set_action(ACTION_FISH);
5220                                 p_ptr->redraw |= (PR_STATE);
5221                                 break;
5222                         }
5223                         case ART_JONES:
5224                         {
5225                                 if (!get_aim_dir(&dir)) return;
5226 #ifdef JP
5227                                 msg_print("¥à¥Á¤ò¿­¤Ð¤·¤¿¡£");
5228 #else
5229                                 msg_print("You stretched your wip.");
5230 #endif
5231
5232                                 fetch(dir, 500, TRUE);
5233                                 o_ptr->timeout = rand_int(25) + 25;
5234                                 break;
5235                         }
5236                         case ART_ARRYU:
5237                         {
5238                                 bool pet = (randint(5) != 1);
5239
5240                                 if (summon_specific((pet ? -1 : 0), py, px, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, TRUE, FALSE, pet, FALSE, !pet))
5241                                 {
5242
5243                                         if (pet)
5244 #ifdef JP
5245                                                 msg_print("¥Ï¥¦¥ó¥É¤¬¤¢¤Ê¤¿¤Î²¼ËͤȤ·¤Æ½Ð¸½¤·¤¿¡£");
5246 #else
5247                                         msg_print("A group of hounds appear as your servant.");
5248 #endif
5249
5250                                         else
5251 #ifdef JP
5252                                                 msg_print("¥Ï¥¦¥ó¥É¤Ï¤¢¤Ê¤¿¤Ë²ç¤ò¸þ¤±¤Æ¤¤¤ë¡ª");
5253 #else
5254                                                 msg_print("A group of hounds appear as your enemy!");
5255 #endif
5256
5257                                 }
5258
5259                                 o_ptr->timeout = 300 + randint(150);
5260                                 break;
5261                         }
5262
5263                         case ART_GAEBOLG:
5264                         {
5265 #ifdef JP
5266                                 msg_print("¥¹¥Ô¥¢¤ÏâÁ¤·¤¯µ±¤¤¤¿...");
5267 #else
5268                                 msg_print("Your spear grows brightly...");
5269 #endif
5270
5271                                 if (!get_aim_dir(&dir)) return;
5272                                 fire_ball(GF_LITE, dir, 200, 3);
5273                                 o_ptr->timeout = rand_int(200) + 200;
5274                                 break;
5275                         }
5276
5277                         case ART_INROU:
5278                         {
5279                                 int count = 0, i;
5280                                 monster_type *m_ptr;
5281 #ifndef JP
5282                                 cptr kakusan = "";
5283 #endif
5284
5285                                 if (summon_named_creature(py, px, MON_SUKE, FALSE, FALSE, TRUE, TRUE))
5286                                 {
5287 #ifdef JP
5288                                         msg_print("¡Ø½õ¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
5289 #else
5290                                         msg_print("Suke-san apperars.");
5291                                         kakusan = "Suke-san";
5292 #endif
5293                                         count++;
5294                                 }
5295                                 if (summon_named_creature(py, px, MON_KAKU, FALSE, FALSE, TRUE, TRUE))
5296                                 {
5297 #ifdef JP
5298                                         msg_print("¡Ø³Ê¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
5299 #else
5300                                         msg_print("Kaku-san appears.");
5301                                         kakusan = "Kaku-san";
5302 #endif
5303                                         count++;
5304                                 }
5305                                 if (!count)
5306                                 {
5307                                         for (i = m_max - 1; i > 0; i--)
5308                                         {
5309                                                 m_ptr = &m_list[i];
5310                                                 if (!m_ptr->r_idx) continue;
5311                                                 if (!((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) continue;
5312                                                 if (!los(m_ptr->fy, m_ptr->fx, py, px)) continue;
5313                                                 count++;
5314                                                 break;
5315                                         }
5316                                 }
5317
5318                                 if (count)
5319                                 {
5320 #ifdef JP
5321                                         msg_print("¡Ö¼Ô¤É¤â¡¢¤Ò¤«¤¨¤ª¤í¤¦¡ª¡ª¡ª¤³¤Î¤ªÊý¤ò¤É¤Ê¤¿¤È¤³¤³¤í¤¨¤ë¡£¡×");
5322 #else
5323                                         msg_format("%^s says 'WHO do you think this person is! Bow your head, down your knees!'", kakusan);
5324 #endif
5325
5326                                         sukekaku = TRUE;
5327                                         stun_monsters(120);
5328                                         confuse_monsters(120);
5329                                         turn_monsters(120);
5330                                         stasis_monsters(120);
5331                                         sukekaku = FALSE;
5332                                 }
5333                                 else
5334                                 {
5335 #ifdef JP
5336                                         msg_print("¤·¤«¤·¡¢²¿¤âµ¯¤­¤Ê¤«¤Ã¤¿¡£");
5337 #else
5338                                         msg_print("Nothing happen.");
5339 #endif
5340                                 }
5341                                 o_ptr->timeout = rand_int(150) + 150;
5342                                 break;
5343                         }
5344
5345                         case ART_HYOUSIGI:
5346                         {
5347 #ifdef JP
5348                                 msg_print("Çï»ÒÌÚ¤òÂǤä¿¡£");
5349 #else
5350                                 msg_print("You beat Your wooden clappers.");
5351 #endif
5352                                 aggravate_monsters(0);
5353                                 break;
5354                         }
5355
5356                         case ART_MATOI:
5357                         case ART_AEGISFANG:
5358                         {
5359                                 set_hero(randint(25)+25, FALSE);
5360                                 hp_player(10);
5361                                 o_ptr->timeout = rand_int(30) + 30;
5362                                 break;
5363                         }
5364
5365                         case ART_EARENDIL:
5366                         {
5367                                 (void)set_poisoned(0);
5368                                 (void)set_confused(0);
5369                                 (void)set_blind(0);
5370                                 (void)set_stun(0);
5371                                 (void)set_cut(0);
5372                                 (void)set_image(0);
5373
5374                                 o_ptr->timeout = 100;
5375                                 break;
5376                         }
5377
5378                         case ART_BOLISHOI:
5379                         {
5380                                 if (!get_aim_dir(&dir)) return;
5381                                 (void)charm_animal(dir, p_ptr->lev);
5382
5383                                 o_ptr->timeout = 200;
5384                                 break;
5385                         }
5386
5387                         case ART_ARUNRUTH:
5388                         {
5389 #ifdef JP
5390                                 msg_print("¥½¡¼¥É¤¬Ã¸¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
5391 #else
5392                                 msg_print("Your sword glows a pale blue...");
5393 #endif
5394                                 if (!get_aim_dir(&dir)) return;
5395                                 fire_bolt(GF_COLD, dir, damroll(12, 8));
5396                                 o_ptr->timeout = 50;
5397                                 break;
5398                         }
5399                         case ART_BLOOD:
5400                         {
5401                                 int dummy, i;
5402 #ifdef JP
5403                                 msg_print("³ù¤¬ÌÀ¤ë¤¯µ±¤¤¤¿...");
5404 #else
5405                                 msg_print("Your scythe glows brightly!");
5406 #endif
5407                                 o_ptr->art_flags1 = a_info[ART_BLOOD].flags1;
5408                                 o_ptr->art_flags2 = a_info[ART_BLOOD].flags2;
5409                                 dummy = randint(2)+randint(2);
5410                                 for (i = 0; i < dummy; i++)
5411                                         o_ptr->art_flags1 |= (TR1_CHAOTIC << rand_int(18));
5412                                 dummy = randint(2);
5413                                 for (i = 0; i < dummy; i++)
5414                                         random_resistance(o_ptr, FALSE, randint(34) + 4);
5415                                 dummy = 2;
5416                                 for (i = 0; i < dummy; i++)
5417                                 {
5418                                         int tmp = rand_int(11);
5419                                         if (tmp < 6) o_ptr->art_flags1 |= (TR1_STR << tmp);
5420                                         else o_ptr->art_flags1 |= (TR1_STEALTH << (tmp - 6));
5421                                 }
5422                                 o_ptr->timeout = 3333;
5423                                 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
5424                                 p_ptr->update |= (PU_BONUS | PU_HP);
5425                                 break;
5426                         }
5427                         case ART_KESHO:
5428                         {
5429 #ifdef JP
5430                                 msg_print("Î϶¯¤¯»Í¸Ô¤òƧ¤ó¤À¡£");
5431 #else
5432                                 msg_print("You stamp. (as if you are in a ring.)");
5433 #endif
5434                                 (void)set_hero(randint(20) + 20, FALSE);
5435                                 dispel_evil(p_ptr->lev * 3);
5436                                 o_ptr->timeout = 100 + randint(100);
5437                                 break;
5438                         }
5439                         case ART_MOOK:
5440                         {
5441 #ifdef JP
5442                                 msg_print("¥¯¥í¡¼¥¯¤¬Çò¤¯µ±¤¤¤¿...");
5443 #else
5444                                 msg_print("Your cloak grows white.");
5445 #endif
5446                                 (void)set_oppose_cold(randint(20) + 20, FALSE);
5447                                 o_ptr->timeout = 40 + randint(40);
5448                                 break;
5449                         }
5450                         case ART_VIOLET:
5451                         {
5452 #ifdef JP
5453                                 msg_print("¥à¥Á¤«¤é±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
5454 #else
5455                                 msg_print("The whip lets out a shrill wail...");
5456 #endif
5457
5458                                 k = 3 * p_ptr->lev;
5459                                 (void)set_protevil(randint(25) + k, FALSE);
5460                                 o_ptr->timeout = rand_int(225) + 225;
5461                                 break;
5462                         }
5463                         case ART_JIZO:
5464                         {
5465                                 bool pet = (randint(5) != 1);
5466
5467                                 if (summon_named_creature(py, px, MON_JIZOTAKO, FALSE, TRUE, FALSE, pet))
5468                                 {
5469                                         if (pet)
5470 #ifdef JP
5471                                                 msg_print("Âý¤¬¤¢¤Ê¤¿¤Î²¼ËͤȤ·¤Æ½Ð¸½¤·¤¿¡£");
5472 #else
5473                                         msg_print("A group of octopuses appear as your servant.");
5474 #endif
5475
5476                                         else
5477 #ifdef JP
5478                                                 msg_print("Âý¤Ï¤¢¤Ê¤¿¤òâˤó¤Ç¤¤¤ë¡ª");
5479 #else
5480                                                 msg_print("A group of octopuses appear as your enemy!");
5481 #endif
5482
5483                                 }
5484
5485                                 o_ptr->timeout = 300 + randint(150);
5486                                 break;
5487                         }
5488
5489                         case ART_FUNDIN:
5490                         {
5491 #ifdef JP
5492                                 msg_print("Å´µå¤ÏÊÕ¤ê¤òÁ±¤Î¥ª¡¼¥é¤ÇËþ¤¿¤·¤¿...");
5493 #else
5494                                 msg_print("The iron ball floods the area with goodness...");
5495 #endif
5496
5497                                 dispel_evil(p_ptr->lev * 5);
5498                                 o_ptr->timeout = rand_int(100) + 100;
5499                                 break;
5500                         }
5501
5502                         case ART_NIGHT:
5503                         {
5504 #ifdef JP
5505                                 msg_print("¥¢¥ß¥å¥ì¥Ã¥È¤¬¿¼¤¤°Ç¤Ëʤ¤ï¤ì¤¿...");
5506 #else
5507                                 msg_print("nanka.");
5508 #endif
5509                                 if (!get_aim_dir(&dir)) return;
5510                                 fire_ball(GF_DARK, dir, 250, 4);
5511                                 o_ptr->timeout = rand_int(150) + 150;
5512                                 break;
5513                         }
5514                 }
5515
5516                 /* Window stuff */
5517                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5518
5519                 /* Done */
5520                 return;
5521         }
5522
5523         else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3 == ESSENCE_TMP_RES_ACID))
5524         {
5525                 (void)set_oppose_acid(randint(20) + 20, FALSE);
5526                 o_ptr->timeout = rand_int(50) + 50;
5527                 return;
5528         }
5529
5530         else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3 == ESSENCE_TMP_RES_ELEC))
5531         {
5532                 (void)set_oppose_elec(randint(20) + 20, FALSE);
5533                 o_ptr->timeout = rand_int(50) + 50;
5534                 return;
5535         }
5536
5537         else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3 == ESSENCE_TMP_RES_FIRE))
5538         {
5539                 (void)set_oppose_fire(randint(20) + 20, FALSE);
5540                 o_ptr->timeout = rand_int(50) + 50;
5541                 return;
5542         }
5543
5544         else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3 == ESSENCE_TMP_RES_COLD))
5545         {
5546                 (void)set_oppose_cold(randint(20) + 20, FALSE);
5547                 o_ptr->timeout = rand_int(50) + 50;
5548                 return;
5549         }
5550
5551         else if ((o_ptr->tval > TV_CAPTURE) && (o_ptr->xtra3 == ESSENCE_EARTHQUAKE))
5552         {
5553                 earthquake(py, px, 5);
5554                 o_ptr->timeout = 100 + randint(100);
5555
5556                 /* Window stuff */
5557                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5558
5559                 /* Done */
5560                 return;
5561         }
5562
5563
5564         else if (o_ptr->name2 == EGO_TRUMP)
5565         {
5566                 teleport_player(100);
5567                 o_ptr->timeout = 50 + randint(50);
5568
5569                 /* Window stuff */
5570                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5571
5572                 /* Done */
5573                 return;
5574         }
5575
5576
5577         else if (o_ptr->name2 == EGO_LITE_ILLUMINATION)
5578         {
5579                 if (!o_ptr->xtra4 && ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN)))
5580                 {
5581                         msg_print("dzÎÁ¤¬¤Ê¤¤¡£");
5582                         energy_use = 0;
5583                         return;
5584                 }
5585                 lite_area(damroll(2, 15), 3);
5586                 o_ptr->timeout = rand_int(10) + 10;
5587
5588                 /* Window stuff */
5589                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5590
5591                 return;
5592         }
5593
5594
5595         else if (o_ptr->name2 == EGO_EARTHQUAKES)
5596         {
5597                 earthquake(py, px, 5);
5598                 o_ptr->timeout = 100 + randint(100);
5599
5600                 /* Window stuff */
5601                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5602
5603                 /* Done */
5604                 return;
5605         }
5606
5607
5608         else if (o_ptr->name2 == EGO_JUMP)
5609         {
5610                 teleport_player(10);
5611                 o_ptr->timeout = 10 + randint(10);
5612
5613                 /* Window stuff */
5614                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5615
5616                 /* Done */
5617                 return;
5618         }
5619
5620
5621         /* Hack -- Dragon Scale Mail can be activated as well */
5622         else if (o_ptr->tval == TV_DRAG_ARMOR)
5623         {
5624                 /* Get a direction for breathing (or abort) */
5625                 if (!get_aim_dir(&dir)) return;
5626
5627                 /* Branch on the sub-type */
5628                 switch (o_ptr->sval)
5629                 {
5630                         case SV_DRAGON_BLUE:
5631                         {
5632 #ifdef JP
5633                                 msg_print("¤¢¤Ê¤¿¤Ï°ðºÊ¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5634 #else
5635                                 msg_print("You breathe lightning.");
5636 #endif
5637
5638                                 fire_ball(GF_ELEC, dir, 100, -2);
5639                                 o_ptr->timeout = rand_int(150) + 150;
5640                                 break;
5641                         }
5642
5643                         case SV_DRAGON_WHITE:
5644                         {
5645 #ifdef JP
5646                                 msg_print("¤¢¤Ê¤¿¤ÏÎ䵤¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5647 #else
5648                                 msg_print("You breathe frost.");
5649 #endif
5650
5651                                 fire_ball(GF_COLD, dir, 110, -2);
5652                                 o_ptr->timeout = rand_int(150) + 150;
5653                                 break;
5654                         }
5655
5656                         case SV_DRAGON_BLACK:
5657                         {
5658 #ifdef JP
5659                                 msg_print("¤¢¤Ê¤¿¤Ï»À¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5660 #else
5661                                 msg_print("You breathe acid.");
5662 #endif
5663
5664                                 fire_ball(GF_ACID, dir, 130, -2);
5665                                 o_ptr->timeout = rand_int(150) + 150;
5666                                 break;
5667                         }
5668
5669                         case SV_DRAGON_GREEN:
5670                         {
5671 #ifdef JP
5672                                 msg_print("¤¢¤Ê¤¿¤ÏÆÇ¥¬¥¹¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5673 #else
5674                                 msg_print("You breathe poison gas.");
5675 #endif
5676
5677                                 fire_ball(GF_POIS, dir, 150, -2);
5678                                 o_ptr->timeout = rand_int(180) + 180;
5679                                 break;
5680                         }
5681
5682                         case SV_DRAGON_RED:
5683                         {
5684 #ifdef JP
5685                                 msg_print("¤¢¤Ê¤¿¤Ï²Ð±ê¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5686 #else
5687                                 msg_print("You breathe fire.");
5688 #endif
5689
5690                                 fire_ball(GF_FIRE, dir, 200, -2);
5691                                 o_ptr->timeout = rand_int(200) + 200;
5692                                 break;
5693                         }
5694
5695                         case SV_DRAGON_MULTIHUED:
5696                         {
5697                                 chance = rand_int(5);
5698 #ifdef JP
5699                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
5700                                            ((chance == 1) ? "°ðºÊ" :
5701                                             ((chance == 2) ? "Î䵤" :
5702                                              ((chance == 3) ? "»À" :
5703                                               ((chance == 4) ? "ÆÇ¥¬¥¹" : "²Ð±ê")))));
5704 #else
5705                                 msg_format("You breathe %s.",
5706                                            ((chance == 1) ? "lightning" :
5707                                             ((chance == 2) ? "frost" :
5708                                              ((chance == 3) ? "acid" :
5709                                               ((chance == 4) ? "poison gas" : "fire")))));
5710 #endif
5711
5712                                 fire_ball(((chance == 1) ? GF_ELEC :
5713                                            ((chance == 2) ? GF_COLD :
5714                                             ((chance == 3) ? GF_ACID :
5715                                              ((chance == 4) ? GF_POIS : GF_FIRE)))),
5716                                           dir, 250, -2);
5717                                 o_ptr->timeout = rand_int(200) + 200;
5718                                 break;
5719                         }
5720
5721                         case SV_DRAGON_BRONZE:
5722                         {
5723 #ifdef JP
5724                                 msg_print("¤¢¤Ê¤¿¤Ïº®Íð¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5725 #else
5726                                 msg_print("You breathe confusion.");
5727 #endif
5728
5729                                 fire_ball(GF_CONFUSION, dir, 120, -2);
5730                                 o_ptr->timeout = rand_int(180) + 180;
5731                                 break;
5732                         }
5733
5734                         case SV_DRAGON_GOLD:
5735                         {
5736 #ifdef JP
5737                                 msg_print("¤¢¤Ê¤¿¤Ï¹ì²»¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5738 #else
5739                                 msg_print("You breathe sound.");
5740 #endif
5741
5742                                 fire_ball(GF_SOUND, dir, 130, -2);
5743                                 o_ptr->timeout = rand_int(180) + 180;
5744                                 break;
5745                         }
5746
5747                         case SV_DRAGON_CHAOS:
5748                         {
5749                                 chance = rand_int(2);
5750 #ifdef JP
5751                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
5752                                            ((chance == 1 ? "¥«¥ª¥¹" : "Îô²½")));
5753 #else
5754                                 msg_format("You breathe %s.",
5755                                            ((chance == 1 ? "chaos" : "disenchantment")));
5756 #endif
5757
5758                                 fire_ball((chance == 1 ? GF_CHAOS : GF_DISENCHANT),
5759                                           dir, 220, -2);
5760                                 o_ptr->timeout = rand_int(200) + 200;
5761                                 break;
5762                         }
5763
5764                         case SV_DRAGON_LAW:
5765                         {
5766                                 chance = rand_int(2);
5767 #ifdef JP
5768                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
5769                                            ((chance == 1 ? "¹ì²»" : "ÇËÊÒ")));
5770 #else
5771                                 msg_format("You breathe %s.",
5772                                            ((chance == 1 ? "sound" : "shards")));
5773 #endif
5774
5775                                 fire_ball((chance == 1 ? GF_SOUND : GF_SHARDS),
5776                                           dir, 230, -2);
5777                                 o_ptr->timeout = rand_int(200) + 200;
5778                                 break;
5779                         }
5780
5781                         case SV_DRAGON_BALANCE:
5782                         {
5783                                 chance = rand_int(4);
5784 #ifdef JP
5785                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿",
5786                                            ((chance == 1) ? "¥«¥ª¥¹" :
5787                                             ((chance == 2) ? "Îô²½" :
5788                                              ((chance == 3) ? "¹ì²»" : "ÇËÊÒ"))));
5789 #else
5790                                 msg_format("You breathe %s.",
5791                                            ((chance == 1) ? "chaos" :
5792                                             ((chance == 2) ? "disenchantment" :
5793                                              ((chance == 3) ? "sound" : "shards"))));
5794 #endif
5795
5796                                 fire_ball(((chance == 1) ? GF_CHAOS :
5797                                            ((chance == 2) ? GF_DISENCHANT :
5798                                             ((chance == 3) ? GF_SOUND : GF_SHARDS))),
5799                                           dir, 250, -2);
5800                                 o_ptr->timeout = rand_int(200) + 200;
5801                                 break;
5802                         }
5803
5804                         case SV_DRAGON_SHINING:
5805                         {
5806                                 chance = rand_int(2);
5807 #ifdef JP
5808                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
5809                                            ((chance == 0 ? "Á®¸÷" : "°Å¹õ")));
5810 #else
5811                                 msg_format("You breathe %s.",
5812                                            ((chance == 0 ? "light" : "darkness")));
5813 #endif
5814
5815                                 fire_ball((chance == 0 ? GF_LITE : GF_DARK), dir, 200, -2);
5816                                 o_ptr->timeout = rand_int(200) + 200;
5817                                 break;
5818                         }
5819
5820                         case SV_DRAGON_POWER:
5821                         {
5822 #ifdef JP
5823 msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5824 #else
5825                                 msg_print("You breathe the elements.");
5826 #endif
5827
5828                                 fire_ball(GF_MISSILE, dir, 300, -3);
5829                                 o_ptr->timeout = rand_int(200) + 200;
5830                                 break;
5831                         }
5832                 }
5833
5834                 /* Window stuff */
5835                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5836
5837                 /* Success */
5838                 return;
5839         }
5840
5841         else if (o_ptr->tval == TV_RING)
5842         {
5843                 if (o_ptr->name2)
5844                 {
5845                         bool success = TRUE;
5846
5847                         switch (o_ptr->name2)
5848                         {
5849                         case EGO_RING_HERO:
5850                                 (void)set_afraid(0);
5851                                 (void)set_hero(randint(25) + 25, FALSE);
5852                                 (void)hp_player(10);
5853                                 o_ptr->timeout = randint(100)+100;
5854                                 break;
5855                         case EGO_RING_MAGIC_MIS:
5856                                 if (!get_aim_dir(&dir)) return;
5857                                 fire_bolt(GF_MISSILE, dir, damroll(2, 6));
5858                                 o_ptr->timeout = 2;
5859                                 break;
5860                         case EGO_RING_FIRE_BOLT:
5861                                 if (!get_aim_dir(&dir)) return;
5862                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
5863                                 o_ptr->timeout = rand_int(8) + 8;
5864                                 break;
5865                         case EGO_RING_COLD_BOLT:
5866                                 if (!get_aim_dir(&dir)) return;
5867                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
5868                                 o_ptr->timeout = rand_int(7) + 7;
5869                                 break;
5870                         case EGO_RING_ELEC_BOLT:
5871                                 if (!get_aim_dir(&dir)) return;
5872                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
5873                                 o_ptr->timeout = rand_int(5) + 5;
5874                                 break;
5875                         case EGO_RING_ACID_BOLT:
5876                                 if (!get_aim_dir(&dir)) return;
5877                                 fire_bolt(GF_FIRE, dir, damroll(5, 8));
5878                                 o_ptr->timeout = rand_int(6) + 6;
5879                                 break;
5880                         case EGO_RING_MANA_BOLT:
5881                                 if (!get_aim_dir(&dir)) return;
5882                                 fire_bolt(GF_MANA, dir, 120);
5883                                 o_ptr->timeout = rand_int(120)+120;
5884                                 break;
5885                         case EGO_RING_FIRE_BALL:
5886                                 if (!get_aim_dir(&dir)) return;
5887                                 fire_ball(GF_FIRE, dir, 100, 2);
5888                                 o_ptr->timeout = rand_int(80) + 80;
5889                                 break;
5890                         case EGO_RING_COLD_BALL:
5891                                 if (!get_aim_dir(&dir)) return;
5892                                 fire_ball(GF_COLD, dir, 100, 2);
5893                                 o_ptr->timeout = rand_int(80) + 80;
5894                                 break;
5895                         case EGO_RING_ELEC_BALL:
5896                                 if (!get_aim_dir(&dir)) return;
5897                                 fire_ball(GF_ELEC, dir, 100, 2);
5898                                 o_ptr->timeout = rand_int(80) + 80;
5899                                 break;
5900                         case EGO_RING_ACID_BALL:
5901                                 if (!get_aim_dir(&dir)) return;
5902                                 fire_ball(GF_ACID, dir, 100, 2);
5903                                 o_ptr->timeout = rand_int(80) + 80;
5904                                 break;
5905                         case EGO_RING_MANA_BALL:
5906                                 if (!get_aim_dir(&dir)) return;
5907                                 fire_ball(GF_MANA, dir, 250, 2);
5908                                 o_ptr->timeout = 300;
5909                                 break;
5910                         case EGO_RING_DRAGON_F:
5911                                 if (!get_aim_dir(&dir)) return;
5912                                 fire_ball(GF_FIRE, dir, 200, -2);
5913                                 if (o_ptr->sval == SV_RING_FLAMES)
5914                                 {
5915                                         (void)set_oppose_fire(randint(20) + 20, FALSE);
5916                                         o_ptr->timeout = 200;
5917                                 }
5918                                 else o_ptr->timeout = 250;
5919                                 break;
5920                         case EGO_RING_DRAGON_C:
5921                                 if (!get_aim_dir(&dir)) return;
5922                                 fire_ball(GF_COLD, dir, 200, -2);
5923                                 if (o_ptr->sval == SV_RING_ICE)
5924                                 {
5925                                         (void)set_oppose_cold(randint(20) + 20, FALSE);
5926                                         o_ptr->timeout = 200;
5927                                 }
5928                                 else o_ptr->timeout = 250;
5929                                 break;
5930                         case EGO_RING_M_DETECT:
5931                                 (void)detect_monsters_invis(255);
5932                                 (void)detect_monsters_normal(255);
5933                                 o_ptr->timeout = 150;
5934                                 break;
5935                         case EGO_RING_D_SPEED:
5936                                 (void)set_fast(randint(30) + 15, FALSE);
5937                                 o_ptr->timeout = 100;
5938                                 break;
5939                         case EGO_RING_BERSERKER:
5940                                 (void)set_shero(randint(25) + 25, FALSE);
5941                                 o_ptr->timeout = rand_int(75)+75;
5942                                 break;
5943                         case EGO_RING_TELE_AWAY:
5944                                 if (!get_aim_dir(&dir)) return;
5945                                 teleport_monster(dir);
5946                                 o_ptr->timeout = 150;
5947                                 break;
5948                         case EGO_RING_TRUE:
5949                         {
5950                                 int v = randint(25)+25;
5951                                 (void)set_afraid(0);
5952                                 (void)set_hero(v, FALSE);
5953                                 (void)hp_player(10);
5954                                 (void)set_blessed(v, FALSE);
5955                                 (void)set_oppose_acid(v, FALSE);
5956                                 (void)set_oppose_elec(v, FALSE);
5957                                 (void)set_oppose_fire(v, FALSE);
5958                                 (void)set_oppose_cold(v, FALSE);
5959                                 (void)set_oppose_pois(v, FALSE);
5960                                 (void)set_ultimate_res(v, FALSE);
5961                                 o_ptr->timeout = 777;
5962                                 break;
5963                         }
5964                         default:
5965                                 success = FALSE;
5966                                 break;
5967                         }
5968                         if (success) return;
5969                 }
5970
5971                 /* Get a direction for breathing (or abort) */
5972                 if (!get_aim_dir(&dir)) return;
5973
5974                 switch (o_ptr->sval)
5975                 {
5976                         case SV_RING_ACID:
5977                         {
5978                                 fire_ball(GF_ACID, dir, 100, 2);
5979                                 (void)set_oppose_acid(randint(20) + 20, FALSE);
5980                                 o_ptr->timeout = rand_int(50) + 50;
5981                                 break;
5982                         }
5983
5984                         case SV_RING_ICE:
5985                         {
5986                                 fire_ball(GF_COLD, dir, 100, 2);
5987                                 (void)set_oppose_cold(randint(20) + 20, FALSE);
5988                                 o_ptr->timeout = rand_int(50) + 50;
5989                                 break;
5990                         }
5991
5992                         case SV_RING_FLAMES:
5993                         {
5994                                 fire_ball(GF_FIRE, dir, 100, 2);
5995                                 (void)set_oppose_fire(randint(20) + 20, FALSE);
5996                                 o_ptr->timeout = rand_int(50) + 50;
5997                                 break;
5998                         }
5999
6000                         case SV_RING_ELEC:
6001                         {
6002                                 fire_ball(GF_ELEC, dir, 100, 2);
6003                                 (void)set_oppose_elec(randint(20) + 20, FALSE);
6004                                 o_ptr->timeout = rand_int(50) + 50;
6005                                 break;
6006                         }
6007                 }
6008
6009                 /* Window stuff */
6010                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
6011
6012                 /* Success */
6013                 return;
6014         }
6015
6016         else if (o_ptr->tval == TV_AMULET)
6017         {
6018                 if (o_ptr->name2)
6019                 {
6020                         switch (o_ptr->name2)
6021                         {
6022                         case EGO_AMU_IDENT:
6023                                 if (!ident_spell(FALSE)) return;
6024                                 o_ptr->timeout = 10;
6025                                 break;
6026                         case EGO_AMU_CHARM:
6027                                 if (!get_aim_dir(&dir)) return;
6028                                 charm_monster(dir, MAX(20, p_ptr->lev));
6029                                 o_ptr->timeout = 200;
6030                                 break;
6031                         case EGO_AMU_JUMP:
6032                                 teleport_player(10);
6033                                 o_ptr->timeout = rand_int(10) + 10;
6034                                 break;
6035                         case EGO_AMU_TELEPORT:
6036                                 teleport_player(100);
6037                                 o_ptr->timeout = rand_int(50) + 50;
6038                                 break;
6039                         case EGO_AMU_D_DOOR:
6040                                 (void)dimension_door();
6041                                 o_ptr->timeout = 200;
6042                                 break;
6043                         case EGO_AMU_RES_FIRE_:
6044                                 (void)set_oppose_fire(randint(20) + 20, FALSE);
6045                                 o_ptr->timeout = rand_int(50) + 50;
6046                                 break;
6047                         case EGO_AMU_RES_COLD_:
6048                                 (void)set_oppose_cold(randint(20) + 20, FALSE);
6049                                 o_ptr->timeout = rand_int(50) + 50;
6050                                 break;
6051                         case EGO_AMU_RES_ELEC_:
6052                                 (void)set_oppose_elec(randint(20) + 20, FALSE);
6053                                 o_ptr->timeout = rand_int(50) + 50;
6054                                 break;
6055                         case EGO_AMU_RES_ACID_:
6056                                 (void)set_oppose_acid(randint(20) + 20, FALSE);
6057                                 o_ptr->timeout = rand_int(50) + 50;
6058                                 break;
6059                         case EGO_AMU_DETECTION:
6060                                 detect_all(DETECT_RAD_DEFAULT);
6061                                 o_ptr->timeout = rand_int(55)+55;
6062                                 break;
6063                         }
6064                 }
6065                 return;
6066         }
6067
6068         else if (o_ptr->tval == TV_WHISTLE)
6069         {
6070 #if 0
6071                 if (cursed_p(o_ptr))
6072                 {
6073 #ifdef JP
6074                         msg_print("¥«¥ó¹â¤¤²»¤¬¶Á¤­ÅϤä¿¡£");
6075 #else
6076                         msg_print("You produce a shrill whistling sound.");
6077 #endif
6078                         aggravate_monsters(0);
6079                 }
6080                 else
6081 #endif
6082                 {
6083                         int pet_ctr, i;
6084                         u16b *who;
6085                         int max_pet = 0;
6086                         u16b dummy_why;
6087
6088                         /* Allocate the "who" array */
6089                         C_MAKE(who, max_m_idx, u16b);
6090
6091                         /* Process the monsters (backwards) */
6092                         for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
6093                         {
6094                                 if (is_pet(&m_list[pet_ctr]) && (p_ptr->riding != pet_ctr))
6095                                   who[max_pet++] = pet_ctr;
6096                         }
6097
6098                         /* Select the sort method */
6099                         ang_sort_comp = ang_sort_comp_pet;
6100                         ang_sort_swap = ang_sort_swap_hook;
6101
6102                         ang_sort(who, &dummy_why, max_pet);
6103
6104                         /* Process the monsters (backwards) */
6105                         for (i = 0; i < max_pet; i++)
6106                         {
6107                                 pet_ctr = who[i];
6108                                 teleport_to_player(pet_ctr, 100);
6109                         }
6110                 }
6111                 o_ptr->timeout = 100+randint(100);
6112                 return;
6113         }
6114         else if (o_ptr->tval == TV_CAPTURE)
6115         {
6116                 if(!o_ptr->pval)
6117                 {
6118                         bool old_target_pet = target_pet;
6119                         target_pet = TRUE;
6120                         if (!get_aim_dir(&dir))
6121                         {
6122                                 target_pet = old_target_pet;
6123                                 return;
6124                         }
6125                         target_pet = old_target_pet;
6126
6127                         if(fire_ball(GF_CAPTURE, dir, 0, 0))
6128                         {
6129                                 o_ptr->pval = cap_mon;
6130                                 o_ptr->xtra3 = cap_mspeed;
6131                                 o_ptr->xtra4 = cap_hp;
6132                                 o_ptr->xtra5 = cap_maxhp;
6133                                 if (cap_nickname)
6134                                 {
6135                                         cptr t;
6136                                         char *s;
6137                                         char buf[80] = "";
6138
6139                                         if (o_ptr->inscription)
6140                                                 strcpy(buf, quark_str(o_ptr->inscription));
6141                                         s = buf;
6142                                         for (s = buf;*s && (*s != '#'); s++)
6143                                         {
6144 #ifdef JP
6145                                                 if (iskanji(*s)) s++;
6146 #endif
6147                                         }
6148                                         *s = '#';
6149                                         s++;
6150 #ifdef JP
6151  /*nothing*/
6152 #else
6153                                         *s++ = '\'';
6154 #endif
6155                                         t = quark_str(cap_nickname);
6156                                         while (*t)
6157                                         {
6158                                                 *s = *t;
6159                                                 s++;
6160                                                 t++;
6161                                         }
6162 #ifdef JP
6163  /*nothing*/
6164 #else
6165                                         *s++ = '\'';
6166 #endif
6167                                         *s = '\0';
6168                                         o_ptr->inscription = quark_add(buf);
6169                                 }
6170                         }
6171                 }
6172                 else
6173                 {
6174                         bool success = FALSE;
6175                         if (!get_rep_dir2(&dir)) return;
6176                         if (cave_floor_bold(py+ddy[dir],px+ddx[dir]))
6177                         {
6178                                 if (place_monster_aux(py + ddy[dir], px + ddx[dir], o_ptr->pval, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE))
6179                                 {
6180                                         if (o_ptr->xtra3) m_list[hack_m_idx_ii].mspeed = o_ptr->xtra3;
6181                                         if (o_ptr->xtra5) m_list[hack_m_idx_ii].max_maxhp = o_ptr->xtra5;
6182                                         if (o_ptr->xtra4) m_list[hack_m_idx_ii].hp = o_ptr->xtra4;
6183                                         m_list[hack_m_idx_ii].maxhp = m_list[hack_m_idx_ii].max_maxhp;
6184                                         if (o_ptr->inscription)
6185                                         {
6186                                                 char buf[80];
6187                                                 cptr t;
6188 #ifndef JP
6189                                                 bool quote = FALSE;
6190 #endif
6191
6192                                                 t = quark_str(o_ptr->inscription);
6193                                                 for (t = quark_str(o_ptr->inscription);*t && (*t != '#'); t++)
6194                                                 {
6195 #ifdef JP
6196                                                         if (iskanji(*t)) t++;
6197 #endif
6198                                                 }
6199                                                 if (*t)
6200                                                 {
6201                                                         char *s = buf;
6202                                                         t++;
6203 #ifdef JP
6204                                                         /* nothing */
6205 #else
6206                                                         if (*t =='\'')
6207                                                         {
6208                                                                 t++;
6209                                                                 quote = TRUE;
6210                                                         }
6211 #endif
6212                                                         while(*t)
6213                                                         {
6214                                                                 *s = *t;
6215                                                                 t++;
6216                                                                 s++;
6217                                                         }
6218 #ifdef JP
6219                                                         /* nothing */
6220 #else
6221                                                         if (quote && *(s-1) =='\'')
6222                                                                 s--;
6223 #endif
6224                                                         *s = '\0';
6225                                                         m_list[hack_m_idx_ii].nickname = quark_add(buf);
6226                                                         t = quark_str(o_ptr->inscription);
6227                                                         s = buf;
6228                                                         while(*t && (*t != '#'))
6229                                                         {
6230                                                                 *s = *t;
6231                                                                 t++;
6232                                                                 s++;
6233                                                         }
6234                                                         *s = '\0';
6235                                                         o_ptr->inscription = quark_add(buf);
6236                                                 }
6237                                         }
6238                                         o_ptr->pval = 0;
6239                                         o_ptr->xtra3 = 0;
6240                                         o_ptr->xtra4 = 0;
6241                                         o_ptr->xtra5 = 0;
6242                                         success = TRUE;
6243                                 }
6244                         }
6245                         if (!success)
6246 #ifdef JP
6247                                 msg_print("¤ª¤Ã¤È¡¢²òÊü¤Ë¼ºÇÔ¤·¤¿¡£");
6248 #else
6249                                 msg_print("Oops.  You failed to release your pet.");
6250 #endif
6251                 }
6252                 return;
6253         }
6254
6255         /* Mistake */
6256 #ifdef JP
6257         msg_print("¤ª¤Ã¤È¡¢¤³¤Î¥¢¥¤¥Æ¥à¤Ï»ÏÆ°¤Ç¤­¤Ê¤¤¡£");
6258 #else
6259         msg_print("Oops.  That object cannot be activated.");
6260 #endif
6261
6262 }
6263
6264
6265 void do_cmd_activate(void)
6266 {
6267         int     item;
6268         cptr    q, s;
6269
6270
6271         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
6272         {
6273                 set_action(ACTION_NONE);
6274         }
6275
6276         item_tester_no_ryoute = TRUE;
6277         /* Prepare the hook */
6278         item_tester_hook = item_tester_hook_activate;
6279
6280         /* Get an item */
6281 #ifdef JP
6282         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò»ÏÆ°¤µ¤»¤Þ¤¹¤«? ";
6283         s = "»ÏÆ°¤Ç¤­¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Ê¤¤¡£";
6284 #else
6285         q = "Activate which item? ";
6286         s = "You have nothing to activate.";
6287 #endif
6288
6289         if (!get_item(&item, q, s, (USE_EQUIP))) return;
6290
6291         /* Activate the item */
6292         do_cmd_activate_aux(item);
6293 }
6294
6295
6296 /*
6297  * Hook to determine if an object is useable
6298  */
6299 static bool item_tester_hook_use(object_type *o_ptr)
6300 {
6301         u32b f1, f2, f3;
6302
6303         /* Ammo */
6304         if (o_ptr->tval == p_ptr->tval_ammo)
6305                 return (TRUE);
6306
6307         /* Useable object */
6308         switch (o_ptr->tval)
6309         {
6310                 case TV_SPIKE:
6311                 case TV_STAFF:
6312                 case TV_WAND:
6313                 case TV_ROD:
6314                 case TV_SCROLL:
6315                 case TV_POTION:
6316                 case TV_FOOD:
6317                 {
6318                         return (TRUE);
6319                 }
6320
6321                 default:
6322                 {
6323                         int i;
6324
6325                         /* Not known */
6326                         if (!object_known_p(o_ptr)) return (FALSE);
6327
6328                         /* HACK - only items from the equipment can be activated */
6329                         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6330                         {
6331                                 if (&inventory[i] == o_ptr)
6332                                 {
6333                                         /* Extract the flags */
6334                                         object_flags(o_ptr, &f1, &f2, &f3);
6335
6336                                         /* Check activation flag */
6337                                         if (f3 & TR3_ACTIVATE) return (TRUE);
6338                                 }
6339                         }
6340                 }
6341         }
6342
6343         /* Assume not */
6344         return (FALSE);
6345 }
6346
6347
6348 /*
6349  * Use an item
6350  * XXX - Add actions for other item types
6351  */
6352 void do_cmd_use(void)
6353 {
6354         int         item;
6355         object_type *o_ptr;
6356         cptr        q, s;
6357
6358         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
6359         {
6360                 set_action(ACTION_NONE);
6361         }
6362
6363         item_tester_no_ryoute = TRUE;
6364         /* Prepare the hook */
6365         item_tester_hook = item_tester_hook_use;
6366
6367         /* Get an item */
6368 #ifdef JP
6369 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
6370 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
6371 #else
6372         q = "Use which item? ";
6373         s = "You have nothing to use.";
6374 #endif
6375
6376         if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
6377
6378         /* Get the item (in the pack) */
6379         if (item >= 0)
6380         {
6381                 o_ptr = &inventory[item];
6382         }
6383         /* Get the item (on the floor) */
6384         else
6385         {
6386                 o_ptr = &o_list[0 - item];
6387         }
6388
6389         switch (o_ptr->tval)
6390         {
6391                 /* Spike a door */
6392                 case TV_SPIKE:
6393                 {
6394                         do_cmd_spike();
6395                         break;
6396                 }
6397
6398                 /* Eat some food */
6399                 case TV_FOOD:
6400                 {
6401                         do_cmd_eat_food_aux(item);
6402                         break;
6403                 }
6404
6405                 /* Aim a wand */
6406                 case TV_WAND:
6407                 {
6408                         do_cmd_aim_wand_aux(item);
6409                         break;
6410                 }
6411
6412                 /* Use a staff */
6413                 case TV_STAFF:
6414                 {
6415                         do_cmd_use_staff_aux(item);
6416                         break;
6417                 }
6418
6419                 /* Zap a rod */
6420                 case TV_ROD:
6421                 {
6422                         do_cmd_zap_rod_aux(item);
6423                         break;
6424                 }
6425
6426                 /* Quaff a potion */
6427                 case TV_POTION:
6428                 {
6429                         do_cmd_quaff_potion_aux(item);
6430                         break;
6431                 }
6432
6433                 /* Read a scroll */
6434                 case TV_SCROLL:
6435                 {
6436                         /* Check some conditions */
6437                         if (p_ptr->blind)
6438                         {
6439 #ifdef JP
6440 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡£");
6441 #else
6442                                 msg_print("You can't see anything.");
6443 #endif
6444
6445                                 return;
6446                         }
6447                         if (no_lite())
6448                         {
6449 #ifdef JP
6450 msg_print("ÌÀ¤«¤ê¤¬¤Ê¤¤¤Î¤Ç¡¢°Å¤¯¤ÆÆɤá¤Ê¤¤¡£");
6451 #else
6452                                 msg_print("You have no light to read by.");
6453 #endif
6454
6455                                 return;
6456                         }
6457                         if (p_ptr->confused)
6458                         {
6459 #ifdef JP
6460 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡ª");
6461 #else
6462                                 msg_print("You are too confused!");
6463 #endif
6464
6465                                 return;
6466                         }
6467
6468                   do_cmd_read_scroll_aux(item);
6469                   break;
6470                 }
6471
6472                 /* Fire ammo */
6473                 case TV_SHOT:
6474                 case TV_ARROW:
6475                 case TV_BOLT:
6476                 {
6477                         do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
6478                         break;
6479                 }
6480
6481                 /* Activate an artifact */
6482                 default:
6483                 {
6484                         do_cmd_activate_aux(item);
6485                         break;
6486                 }
6487         }
6488 }
6489
6490 static bool select_magic_eater(int mode)
6491 {
6492         int ext=0;
6493         char choice;
6494         bool flag, redraw;
6495         int tval = 0;
6496         int             ask = TRUE, i = 0;
6497         char            out_val[160];
6498
6499         int menu_line = (use_menu ? 1 : 0);
6500
6501 #ifdef ALLOW_REPEAT
6502         int sn;
6503         if (repeat_pull(&sn))
6504         {
6505                 /* Verify the spell */
6506                 if (sn > 71 && !(p_ptr->magic_num1[sn] > k_info[lookup_kind(TV_ROD, i)].pval * (p_ptr->magic_num2[sn] - 1) * 0x10000L))
6507                         return sn;
6508                 else if (sn < 72 && !(p_ptr->magic_num1[sn] < 0x10000))
6509                         return sn;
6510         }
6511         
6512 #endif /* ALLOW_REPEAT */
6513
6514         for (i = 0; i < 108; i++)
6515         {
6516                 if (p_ptr->magic_num2[i]) break;
6517         }
6518         if (i == 108)
6519         {
6520 #ifdef JP
6521                 msg_print("ËâË¡¤ò³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
6522 #else
6523                 msg_print("You don't have any magic!");
6524 #endif
6525                 return -1;
6526         }
6527
6528         if (use_menu)
6529         {
6530                 screen_save();
6531
6532                 while(!tval)
6533                 {
6534 #ifdef JP
6535                         prt(format(" %s ¾ó", (menu_line == 1) ? "¡Õ" : "  "), 2, 14);
6536                         prt(format(" %s ËâË¡ËÀ", (menu_line == 2) ? "¡Õ" : "  "), 3, 14);
6537                         prt(format(" %s ¥í¥Ã¥É", (menu_line == 3) ? "¡Õ" : "  "), 4, 14);
6538                         prt("¤É¤Î¼ïÎà¤ÎËâË¡¤ò»È¤¤¤Þ¤¹¤«¡©", 0, 0);
6539 #else
6540                         prt(format(" %s staff", (menu_line == 1) ? "> " : "  "), 2, 14);
6541                         prt(format(" %s wand", (menu_line == 2) ? "> " : "  "), 3, 14);
6542                         prt(format(" %s rod", (menu_line == 3) ? "> " : "  "), 4, 14);
6543                         prt("Which type of magic do you usu?", 0, 0);
6544 #endif
6545                         choice = inkey();
6546                         switch(choice)
6547                         {
6548                         case ESCAPE:
6549                         case 'z':
6550                         case 'Z':
6551                                 screen_load();
6552                                 return -1;
6553                         case '2':
6554                         case 'j':
6555                         case 'J':
6556                                 menu_line++;
6557                                 break;
6558                         case '8':
6559                         case 'k':
6560                         case 'K':
6561                                 menu_line+= 2;
6562                                 break;
6563                         case '\r':
6564                         case 'x':
6565                         case 'X':
6566                                 ext = (menu_line-1)*36;
6567                                 if (menu_line == 1) tval = TV_STAFF;
6568                                 else if (menu_line == 2) tval = TV_WAND;
6569                                 else tval = TV_ROD;
6570                                 break;
6571                         }
6572                         if (menu_line > 3) menu_line -= 3;
6573                 }
6574                 screen_load();
6575         }
6576         else
6577         {
6578         while (TRUE)
6579         {
6580 #ifdef JP
6581                 if (!get_com("[A] ¾ó, [B] ËâË¡ËÀ, [C] ¥í¥Ã¥É:", &choice, TRUE))
6582 #else
6583                 if (!get_com("[A] staff, [B] wand, [C] rod:", &choice, TRUE))
6584 #endif
6585                 {
6586                         return -1;
6587                 }
6588                 if (choice == 'A' || choice == 'a')
6589                 {
6590                         ext = 0;
6591                         tval = TV_STAFF;
6592                         break;
6593                 }
6594                 if (choice == 'B' || choice == 'b')
6595                 {
6596                         ext = 36;
6597                         tval = TV_WAND;
6598                         break;
6599                 }
6600                 if (choice == 'C' || choice == 'c')
6601                 {
6602                         ext = 72;
6603                         tval = TV_ROD;
6604                         break;
6605                 }
6606         }
6607         }
6608         for (i = ext; i < ext + 36; i++)
6609         {
6610                 if (p_ptr->magic_num2[i])
6611                 {
6612                         if (use_menu) menu_line = i-ext+1;
6613                         break;
6614                 }
6615         }
6616         if (i == ext+36)
6617         {
6618 #ifdef JP
6619                 msg_print("¤½¤Î¼ïÎà¤ÎËâË¡¤Ï³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
6620 #else
6621                 msg_print("You don't have that type of magic!");
6622 #endif
6623                 return -1;
6624         }
6625
6626         /* Nothing chosen yet */
6627         flag = FALSE;
6628
6629         /* No redraw yet */
6630         redraw = FALSE;
6631
6632         /* Build a prompt */
6633 #ifdef JP
6634 (void) strnfmt(out_val, 78, "('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎËâÎϤò»È¤¤¤Þ¤¹¤«¡©");
6635 #else
6636         (void)strnfmt(out_val, 78, "(*=List, ESC=exit) Use which power? ");
6637 #endif
6638         if (use_menu) screen_save();
6639
6640         /* Get a spell from the user */
6641
6642         choice = (always_show_list || use_menu) ? ESCAPE:1;
6643         while (!flag)
6644         {
6645                 if( choice==ESCAPE ) choice = ' '; 
6646                 else if( !get_com(out_val, &choice, FALSE) )break; 
6647
6648                 if (use_menu && choice != ' ')
6649                 {
6650                         switch(choice)
6651                         {
6652                                 case '0':
6653                                 {
6654                                         screen_load();
6655                                         return (FALSE);
6656                                         break;
6657                                 }
6658
6659                                 case '8':
6660                                 case 'k':
6661                                 case 'K':
6662                                 {
6663                                         do
6664                                         {
6665                                                 menu_line += 35;
6666                                                 if (menu_line > 36) menu_line -= 36;
6667                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
6668                                         break;
6669                                 }
6670
6671                                 case '2':
6672                                 case 'j':
6673                                 case 'J':
6674                                 {
6675                                         do
6676                                         {
6677                                                 menu_line++;
6678                                                 if (menu_line > 36) menu_line -= 36;
6679                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
6680                                         break;
6681                                 }
6682
6683                                 case '4':
6684                                 case 'h':
6685                                 case 'H':
6686                                 case '6':
6687                                 case 'l':
6688                                 case 'L':
6689                                 {
6690                                         bool reverse = FALSE;
6691                                         if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
6692                                         if (menu_line > 18)
6693                                         {
6694                                                 menu_line -= 18;
6695                                                 reverse = TRUE;
6696                                         }
6697                                         else menu_line+=18;
6698                                         while(!p_ptr->magic_num2[menu_line+ext-1])
6699                                         {
6700                                                 if (reverse)
6701                                                 {
6702                                                         menu_line--;
6703                                                         if (menu_line < 2) reverse = FALSE;
6704                                                 }
6705                                                 else
6706                                                 {
6707                                                         menu_line++;
6708                                                         if (menu_line > 35) reverse = TRUE;
6709                                                 }
6710                                         }
6711                                         break;
6712                                 }
6713
6714                                 case 'x':
6715                                 case 'X':
6716                                 case '\r':
6717                                 {
6718                                         i = menu_line - 1;
6719                                         ask = FALSE;
6720                                         break;
6721                                 }
6722                         }
6723                 }
6724                 /* Request redraw */
6725                 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
6726                 {
6727                         /* Show the list */
6728                         if (!redraw || use_menu)
6729                         {
6730                                 byte y, x = 0;
6731                                 int ctr, chance;
6732                                 int k_idx;
6733                                 char dummy[80];
6734                                 int x1, y1, level;
6735                                 byte col;
6736
6737                                 strcpy(dummy, "");
6738
6739                                 /* Show list */
6740                                 redraw = TRUE;
6741
6742                                 /* Save the screen */
6743                                 if (!use_menu) screen_save();
6744
6745                                 for (y = 1; y < 20; y++)
6746                                         prt("", y, x);
6747
6748                                 y = 1;
6749
6750                                 /* Print header(s) */
6751 #ifdef JP
6752                                 prt(format("                           %s ¼ºÎ¨                           %s ¼ºÎ¨", (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô"), (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô")), y++, x);
6753 #else
6754                                 prt(format("                           %s Fail                           %s Fail", (tval == TV_ROD ? "  Stat  " : " Charges"), (tval == TV_ROD ? "  Stat  " : " Charges")), y++, x);
6755 #endif
6756
6757                                 /* Print list */
6758                                 for (ctr = 0; ctr < 36; ctr++)
6759                                 {
6760                                         if (!p_ptr->magic_num2[ctr+ext]) continue;
6761
6762                                         k_idx = lookup_kind(tval, ctr);
6763
6764                                         if (use_menu)
6765                                         {
6766                                                 if (ctr == (menu_line-1))
6767 #ifdef JP
6768                                                         strcpy(dummy, "¡Õ");
6769 #else
6770                                                         strcpy(dummy, "> ");
6771 #endif
6772                                                 else strcpy(dummy, "  ");
6773                                                 
6774                                         }
6775                                         /* letter/number for power selection */
6776                                         else
6777                                         {
6778                                                 char letter;
6779                                                 if (ctr < 26)
6780                                                         letter = I2A(ctr);
6781                                                 else
6782                                                         letter = '0' + ctr - 26;
6783                                                 sprintf(dummy, "%c)",letter);
6784                                         }
6785                                         x1 = ((ctr < 18) ? x : x + 40);
6786                                         y1 = ((ctr < 18) ? y + ctr : y + ctr - 18);
6787                                         level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
6788                                         chance = level * 4 / 5 + 20;
6789                                         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
6790                                         level /= 2;
6791                                         if (p_ptr->lev > level)
6792                                         {
6793                                                 chance -= 3 * (p_ptr->lev - level);
6794                                         }
6795                                         if (p_ptr->pseikaku == SEIKAKU_NAMAKE) chance += 10;
6796                                         if (p_ptr->heavy_spell) chance += 20;
6797                                         if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
6798                                         else if (p_ptr->easy_spell) chance-=3;
6799                                         else if (p_ptr->dec_mana) chance-=2;
6800                                         chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
6801                                         /* Stunning makes spells harder */
6802                                         if (p_ptr->stun > 50) chance += 25;
6803                                         else if (p_ptr->stun) chance += 15;
6804
6805                                         if (chance > 95) chance = 95;
6806
6807                                         if(p_ptr->dec_mana) chance--;
6808                                         if (p_ptr->heavy_spell) chance += 5;
6809
6810                                         col = TERM_WHITE;
6811
6812                                         if (k_idx)
6813                                         {
6814                                                 if (tval == TV_ROD)
6815                                                 {
6816                                                         strcat(dummy, format(" %-22.22s ½¼Å¶:%2d/%2d%3d%%", k_name + k_info[k_idx].name, p_ptr->magic_num1[ctr+ext] ? (p_ptr->magic_num1[ctr+ext] - 1) / (0x10000L * k_info[k_idx].pval) +1 : 0, p_ptr->magic_num2[ctr+ext], chance));
6817                                                         if (p_ptr->magic_num1[ctr+ext] > k_info[k_idx].pval * (p_ptr->magic_num2[ctr+ext]-1) * 0x10000L) col = TERM_RED;
6818                                                 }
6819                                                 else
6820                                                 {
6821                                                         strcat(dummy, format(" %-22.22s    %2d/%2d %3d%%", k_name + k_info[k_idx].name, (s16b)(p_ptr->magic_num1[ctr+ext]/0x10000), p_ptr->magic_num2[ctr+ext], chance));
6822                                                         if (p_ptr->magic_num1[ctr+ext] < 0x10000L) col = TERM_RED;
6823                                                 }
6824                                         }
6825                                         else
6826                                                 strcpy(dummy, "");
6827                                         c_prt(col, dummy, y1, x1);
6828                                 }
6829                         }
6830
6831                         /* Hide the list */
6832                         else
6833                         {
6834                                 /* Hide list */
6835                                 redraw = FALSE;
6836
6837                                 /* Restore the screen */
6838                                 screen_load();
6839                         }
6840
6841                         /* Redo asking */
6842                         continue;
6843                 }
6844
6845                 if (!use_menu)
6846                 {
6847                         if (isalpha(choice))
6848                         {
6849                                 /* Note verify */
6850                                 ask = (isupper(choice));
6851
6852                                 /* Lowercase */
6853                                 if (ask) choice = tolower(choice);
6854
6855                                 /* Extract request */
6856                                 i = (islower(choice) ? A2I(choice) : -1);
6857                         }
6858                         else
6859                         {
6860                                 ask = FALSE; /* Can't uppercase digits */
6861
6862                                 i = choice - '0' + 26;
6863                         }
6864                 }
6865
6866                 /* Totally Illegal */
6867                 if ((i < 0) || (i > 36) || !p_ptr->magic_num2[i+ext])
6868                 {
6869                         bell();
6870                         continue;
6871                 }
6872
6873                 if (mode == 0)
6874                 {
6875                         /* Verify it */
6876                         if (ask)
6877                         {
6878                                 char tmp_val[160];
6879
6880                                 /* Prompt */
6881 #ifdef JP
6882                                 (void) strnfmt(tmp_val, 78, "%s¤ò»È¤¤¤Þ¤¹¤«¡© ", k_name + k_info[lookup_kind(tval ,i)].name);
6883 #else
6884                                 (void) strnfmt(tmp_val, 78, "Use %s?", k_name + k_info[lookup_kind(tval ,i)].name);
6885 #endif
6886
6887                                 /* Belay that order */
6888                                 if (!get_check(tmp_val)) continue;
6889                         }
6890                         if (tval == TV_ROD)
6891                         {
6892                                 if (p_ptr->magic_num1[ext+i]  > k_info[lookup_kind(tval, i)].pval * (p_ptr->magic_num2[ext+i] - 1) * 0x10000L)
6893                                 {
6894 #ifdef JP
6895                                         msg_print("¤½¤ÎËâË¡¤Ï¤Þ¤À½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
6896 #else
6897                                         msg_print("The magic are still charging.");
6898 #endif
6899                                         msg_print(NULL);
6900                                         if (use_menu) ask = TRUE;
6901                                         continue;
6902                                 }
6903                         }
6904                         else
6905                         {
6906                                 if (p_ptr->magic_num1[ext+i] < 0x10000L)
6907                                 {
6908 #ifdef JP
6909                                         msg_print("¤½¤ÎËâË¡¤Ï»ÈÍѲó¿ô¤¬ÀÚ¤ì¤Æ¤¤¤ë¡£");
6910 #else
6911                                         msg_print("The magic has no charges left.");
6912 #endif
6913                                         msg_print(NULL);
6914                                         if (use_menu) ask = TRUE;
6915                                         continue;
6916                                 }
6917                         }
6918                 }
6919
6920                 /* Stop the loop */
6921                 flag = TRUE;
6922         }
6923
6924         /* Restore the screen */
6925         if (redraw) screen_load();
6926
6927         if (!flag) return -1;
6928
6929 #ifdef ALLOW_REPEAT
6930         repeat_push(ext+i);
6931 #endif /* ALLOW_REPEAT */
6932         return ext+i;
6933 }
6934
6935 void do_cmd_magic_eater(void)
6936 {
6937         int item, dir, chance, level, k_idx, tval, sval;
6938         bool use_charge = TRUE;
6939
6940         /* Not when confused */
6941         if (p_ptr->confused)
6942         {
6943 #ifdef JP
6944 msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
6945 #else
6946                 msg_print("You are too confused!");
6947 #endif
6948
6949                 return;
6950         }
6951
6952         item = select_magic_eater(0);
6953         if (item == -1)
6954         {
6955                 energy_use = 0;
6956                 return;
6957         }
6958         if (item > 71) {tval = TV_ROD;sval = item - 72;}
6959         else if (item > 35) {tval = TV_WAND;sval = item - 36;}
6960         else {tval = TV_STAFF;sval = item;}
6961         k_idx = lookup_kind(tval, sval);
6962
6963         level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
6964         chance = level * 4 / 5 + 20;
6965         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
6966         level /= 2;
6967         if (p_ptr->lev > level)
6968         {
6969                 chance -= 3 * (p_ptr->lev - level);
6970         }
6971         if (p_ptr->pseikaku == SEIKAKU_NAMAKE) chance += 10;
6972         if (p_ptr->heavy_spell) chance += 20;
6973         if(p_ptr->dec_mana && p_ptr->easy_spell) chance-=4;
6974         else if (p_ptr->easy_spell) chance-=3;
6975         else if (p_ptr->dec_mana) chance-=2;
6976         chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
6977         /* Stunning makes spells harder */
6978         if (p_ptr->stun > 50) chance += 25;
6979         else if (p_ptr->stun) chance += 15;
6980
6981         if (chance > 95) chance = 95;
6982
6983         if(p_ptr->dec_mana) chance--;
6984         if (p_ptr->heavy_spell) chance += 5;
6985
6986         if (rand_int(100) < chance)
6987         {
6988                 if (flush_failure) flush();
6989
6990 #ifdef JP
6991 msg_print("¼öʸ¤ò¤¦¤Þ¤¯¾§¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡ª");
6992 #else
6993                 msg_format("You failed to get the magic off!");
6994 #endif
6995
6996                 sound(SOUND_FAIL);
6997                 if (randint(100) >= chance)
6998                         chg_virtue(V_CHANCE,-1);
6999                 energy_use = 100;
7000
7001                 return;
7002         }
7003         else
7004         {
7005                 if (tval == TV_ROD)
7006                 {
7007                         if ((sval >= SV_ROD_MIN_DIRECTION) && (sval != SV_ROD_HAVOC))
7008                                 if (!get_aim_dir(&dir)) return;
7009                         rod_effect(sval, dir, &use_charge, TRUE);
7010                         if (!use_charge) return;
7011                 }
7012                 else if (tval == TV_WAND)
7013                 {
7014                         if (!get_aim_dir(&dir)) return;
7015                         wand_effect(sval, dir, TRUE);
7016                 }
7017                 else
7018                 {
7019                         staff_effect(sval, &use_charge, TRUE);
7020                         if (!use_charge) return;
7021                 }
7022                 if (randint(100) < chance)
7023                         chg_virtue(V_CHANCE,1);
7024         }
7025         energy_use = 100;
7026         if (tval == TV_ROD) p_ptr->magic_num1[item] += k_info[k_idx].pval * 0x10000L;
7027         else p_ptr->magic_num1[item] -= 0x10000L;
7028 }