OSDN Git Service

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