OSDN Git Service

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