OSDN Git Service

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