OSDN Git Service

Rumors already includes some excellent rumors. (It was coded temporally.)
[hengbandforosx/hengbandosx.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 #ifdef JP
2080                         msg_print("´¬Êª¤Ë¤Ï¥á¥Ã¥»¡¼¥¸¤¬½ñ¤«¤ì¤Æ¤¤¤ë:");
2081 #else
2082                         msg_print("There is message on the scroll. It says:");
2083 #endif
2084
2085                         msg_print(NULL);
2086                         display_rumor(TRUE);
2087                         msg_print(NULL);
2088 #ifdef JP
2089                         msg_print("´¬Êª¤Ï±ì¤òΩ¤Æ¤Æ¾Ã¤¨µî¤Ã¤¿¡ª");
2090 #else
2091                         msg_print("The scroll disappears in a puff of smoke!");
2092 #endif
2093
2094                         ident = TRUE;
2095                         break;
2096                 }
2097
2098                 case SV_SCROLL_ARTIFACT:
2099                 {
2100                         ident = TRUE;
2101                         if (!artifact_scroll()) used_up = FALSE;
2102                         break;
2103                 }
2104
2105                 case SV_SCROLL_RESET_RECALL:
2106                 {
2107                         ident = TRUE;
2108                         if (!reset_recall()) used_up = FALSE;
2109                         break;
2110                 }
2111         }
2112         }
2113         else if (o_ptr->name1 == ART_GHB)
2114         {
2115 #ifdef JP
2116                 msg_print("»ä¤Ï¶ìÏ«¤·¤Æ¡Ø¥°¥ì¡¼¥¿¡¼¡¦¥Ø¥ë=¥Ó¡¼¥¹¥È¡Ù¤òÅݤ·¤¿¡£");
2117                 msg_print("¤·¤«¤·¼ê¤ËÆþ¤Ã¤¿¤Î¤Ï¤³¤Î¤­¤¿¤Ê¤¤£Ô¥·¥ã¥Ä¤À¤±¤À¤Ã¤¿¡£");
2118 #else
2119                 msg_print("I had a very hard time to kill the Greater hell-beast, ");
2120                 msg_print("but all I got was this lousy t-shirt!");
2121 #endif
2122                 used_up = FALSE;
2123         }
2124         else if (o_ptr->name1 == ART_POWER)
2125         {
2126 #ifdef JP
2127                 msg_print("¡Ö°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤òÅý¤Ù¡¢");
2128                 msg_print(NULL);
2129                 msg_print("°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤ò¸«¤Ä¤±¡¢");
2130                 msg_print(NULL);
2131                 msg_print("°ì¤Ä¤Î»ØÎؤÏÁ´¤Æ¤òÊá¤é¤¨¤Æ");
2132                 msg_print(NULL);
2133                 msg_print("°Å°Ç¤ÎÃæ¤Ë·Ò¤®¤È¤á¤ë¡£¡×");
2134 #else
2135                 msg_print("'One Ring to rule them all, ");
2136                 msg_print(NULL);
2137                 msg_print("One Ring to find them, ");
2138                 msg_print(NULL);
2139                 msg_print("One Ring to bring them all ");
2140                 msg_print(NULL);
2141                 msg_print("and in the darkness bind them.'");
2142 #endif
2143                 used_up = FALSE;
2144         }
2145         else if (o_ptr->tval==TV_PARCHMENT)
2146         {
2147                 cptr q;
2148                 char o_name[MAX_NLEN];
2149                 char buf[1024];
2150
2151                 /* Save screen */
2152                 screen_save();
2153
2154                 q=format("book-%d_jp.txt",o_ptr->sval);
2155
2156                 /* Display object description */
2157                 object_desc(o_name, o_ptr, OD_NAME_ONLY);
2158
2159                 /* Build the filename */
2160                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, q);
2161
2162                 /* Peruse the help file */
2163                 (void)show_file(TRUE, buf, o_name, 0, 0);
2164
2165                 /* Load screen */
2166                 screen_load();
2167
2168                 used_up=FALSE;
2169         }
2170
2171
2172         /* Combine / Reorder the pack (later) */
2173         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2174
2175         if (!(object_is_aware(o_ptr)))
2176         {
2177                 chg_virtue(V_PATIENCE, -1);
2178                 chg_virtue(V_CHANCE, 1);
2179                 chg_virtue(V_KNOWLEDGE, -1);
2180         }
2181
2182         /* The item was tried */
2183         object_tried(o_ptr);
2184
2185         /* An identification was made */
2186         if (ident && !object_is_aware(o_ptr))
2187         {
2188                 object_aware(o_ptr);
2189                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
2190         }
2191
2192         /* Window stuff */
2193         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2194
2195
2196         /* Hack -- allow certain scrolls to be "preserved" */
2197         if (!used_up)
2198         {
2199                 return;
2200         }
2201
2202         sound(SOUND_SCROLL);
2203
2204         /* Destroy a scroll in the pack */
2205         if (item >= 0)
2206         {
2207                 inven_item_increase(item, -1);
2208                 inven_item_describe(item);
2209                 inven_item_optimize(item);
2210         }
2211
2212         /* Destroy a scroll on the floor */
2213         else
2214         {
2215                 floor_item_increase(0 - item, -1);
2216                 floor_item_describe(0 - item);
2217                 floor_item_optimize(0 - item);
2218         }
2219 }
2220
2221
2222 /*
2223  * Hook to determine if an object is readable
2224  */
2225 static bool item_tester_hook_readable(object_type *o_ptr)
2226 {
2227         if ((o_ptr->tval==TV_SCROLL) || (o_ptr->tval==TV_PARCHMENT) || (o_ptr->name1 == ART_GHB) || (o_ptr->name1 == ART_POWER)) return (TRUE);
2228
2229         /* Assume not */
2230         return (FALSE);
2231 }
2232
2233
2234 void do_cmd_read_scroll(void)
2235 {
2236         object_type *o_ptr;
2237         int  item;
2238         cptr q, s;
2239
2240         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
2241         {
2242                 set_action(ACTION_NONE);
2243         }
2244
2245         /* Check some conditions */
2246         if (p_ptr->blind)
2247         {
2248 #ifdef JP
2249                 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡£");
2250 #else
2251                 msg_print("You can't see anything.");
2252 #endif
2253
2254                 return;
2255         }
2256         if (no_lite())
2257         {
2258 #ifdef JP
2259                 msg_print("ÌÀ¤«¤ê¤¬¤Ê¤¤¤Î¤Ç¡¢°Å¤¯¤ÆÆɤá¤Ê¤¤¡£");
2260 #else
2261                 msg_print("You have no light to read by.");
2262 #endif
2263
2264                 return;
2265         }
2266         if (p_ptr->confused)
2267         {
2268 #ifdef JP
2269                 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡£");
2270 #else
2271                 msg_print("You are too confused!");
2272 #endif
2273
2274                 return;
2275         }
2276
2277
2278         /* Restrict choices to scrolls */
2279         item_tester_hook = item_tester_hook_readable;
2280
2281         /* Get an item */
2282 #ifdef JP
2283         q = "¤É¤Î´¬Êª¤òÆɤߤޤ¹¤«? ";
2284         s = "Æɤá¤ë´¬Êª¤¬¤Ê¤¤¡£";
2285 #else
2286         q = "Read which scroll? ";
2287         s = "You have no scrolls to read.";
2288 #endif
2289
2290         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
2291
2292         /* Get the item (in the pack) */
2293         if (item >= 0)
2294         {
2295                 o_ptr = &inventory[item];
2296         }
2297
2298         /* Get the item (on the floor) */
2299         else
2300         {
2301                 o_ptr = &o_list[0 - item];
2302         }
2303
2304         /* Read the scroll */
2305         do_cmd_read_scroll_aux(item, object_is_aware(o_ptr));
2306 }
2307
2308
2309 static int staff_effect(int sval, bool *use_charge, bool magic, bool known)
2310 {
2311         int k;
2312         int ident = FALSE;
2313
2314         /* Analyze the staff */
2315         switch (sval)
2316         {
2317                 case SV_STAFF_DARKNESS:
2318                 {
2319                         if (!(p_ptr->resist_blind) && !(p_ptr->resist_dark))
2320                         {
2321                                 if (set_blind(p_ptr->blind + 3 + randint1(5))) ident = TRUE;
2322                         }
2323                         if (unlite_area(10, 3)) ident = TRUE;
2324                         break;
2325                 }
2326
2327                 case SV_STAFF_SLOWNESS:
2328                 {
2329                         if (set_slow(p_ptr->slow + randint1(30) + 15, FALSE)) ident = TRUE;
2330                         break;
2331                 }
2332
2333                 case SV_STAFF_HASTE_MONSTERS:
2334                 {
2335                         if (speed_monsters()) ident = TRUE;
2336                         break;
2337                 }
2338
2339                 case SV_STAFF_SUMMONING:
2340                 {
2341                         for (k = 0; k < randint1(4); k++)
2342                         {
2343                                 if (summon_specific(0, py, px, dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
2344                                 {
2345                                         ident = TRUE;
2346                                 }
2347                         }
2348                         break;
2349                 }
2350
2351                 case SV_STAFF_TELEPORTATION:
2352                 {
2353                         teleport_player(100, 0L);
2354                         ident = TRUE;
2355                         break;
2356                 }
2357
2358                 case SV_STAFF_IDENTIFY:
2359                 {
2360                         if (!ident_spell(FALSE)) *use_charge = FALSE;
2361                         ident = TRUE;
2362                         break;
2363                 }
2364
2365                 case SV_STAFF_REMOVE_CURSE:
2366                 {
2367                         if (remove_curse())
2368                         {
2369                                 if (magic)
2370                                 {
2371 #ifdef JP
2372                                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
2373 #else
2374                                         msg_print("You feel as if someone is watching over you.");
2375 #endif
2376                                 }
2377                                 else if (!p_ptr->blind)
2378                                 {
2379 #ifdef JP
2380                                         msg_print("¾ó¤Ï°ì½Ö¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
2381 #else
2382                                         msg_print("The staff glows blue for a moment...");
2383 #endif
2384
2385                                 }
2386                                 ident = TRUE;
2387                         }
2388                         break;
2389                 }
2390
2391                 case SV_STAFF_STARLITE:
2392                 {
2393                         int num = damroll(5, 3);
2394                         int y, x;
2395                         int attempts;
2396
2397                         if (!p_ptr->blind && !magic)
2398                         {
2399 #ifdef JP
2400                                 msg_print("¾ó¤ÎÀ褬ÌÀ¤ë¤¯µ±¤¤¤¿...");
2401 #else
2402                                 msg_print("The end of the staff glows brightly...");
2403 #endif
2404
2405                         }
2406                         for (k = 0; k < num; k++)
2407                         {
2408                                 attempts = 1000;
2409
2410                                 while (attempts--)
2411                                 {
2412                                         scatter(&y, &x, py, px, 4, 0);
2413
2414                                         if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
2415
2416                                         if (!player_bold(y, x)) break;
2417                                 }
2418
2419                                 project(0, 0, y, x, damroll(6 + p_ptr->lev / 8, 10), GF_LITE_WEAK,
2420                                                   (PROJECT_BEAM | PROJECT_THRU | PROJECT_GRID | PROJECT_KILL), -1);
2421                         }
2422                         ident = TRUE;
2423                         break;
2424                 }
2425
2426                 case SV_STAFF_LITE:
2427                 {
2428                         if (lite_area(damroll(2, 8), 2)) ident = TRUE;
2429                         break;
2430                 }
2431
2432                 case SV_STAFF_MAPPING:
2433                 {
2434                         map_area(DETECT_RAD_MAP);
2435                         ident = TRUE;
2436                         break;
2437                 }
2438
2439                 case SV_STAFF_DETECT_GOLD:
2440                 {
2441                         if (detect_treasure(DETECT_RAD_DEFAULT)) ident = TRUE;
2442                         if (detect_objects_gold(DETECT_RAD_DEFAULT)) ident = TRUE;
2443                         break;
2444                 }
2445
2446                 case SV_STAFF_DETECT_ITEM:
2447                 {
2448                         if (detect_objects_normal(DETECT_RAD_DEFAULT)) ident = TRUE;
2449                         break;
2450                 }
2451
2452                 case SV_STAFF_DETECT_TRAP:
2453                 {
2454                         if (detect_traps(DETECT_RAD_DEFAULT, known)) ident = TRUE;
2455                         break;
2456                 }
2457
2458                 case SV_STAFF_DETECT_DOOR:
2459                 {
2460                         if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
2461                         if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
2462                         break;
2463                 }
2464
2465                 case SV_STAFF_DETECT_INVIS:
2466                 {
2467                         if (detect_monsters_invis(DETECT_RAD_DEFAULT)) ident = TRUE;
2468                         break;
2469                 }
2470
2471                 case SV_STAFF_DETECT_EVIL:
2472                 {
2473                         if (detect_monsters_evil(DETECT_RAD_DEFAULT)) ident = TRUE;
2474                         break;
2475                 }
2476
2477                 case SV_STAFF_CURE_LIGHT:
2478                 {
2479                         if (hp_player(damroll(2, 8))) ident = TRUE;
2480                         if (set_shero(0,TRUE)) ident = TRUE;
2481                         break;
2482                 }
2483
2484                 case SV_STAFF_CURING:
2485                 {
2486                         if (set_blind(0)) ident = TRUE;
2487                         if (set_poisoned(0)) ident = TRUE;
2488                         if (set_confused(0)) ident = TRUE;
2489                         if (set_stun(0)) ident = TRUE;
2490                         if (set_cut(0)) ident = TRUE;
2491                         if (set_image(0)) ident = TRUE;
2492                         if (set_shero(0,TRUE)) ident = TRUE;
2493                         break;
2494                 }
2495
2496                 case SV_STAFF_HEALING:
2497                 {
2498                         if (hp_player(300)) ident = TRUE;
2499                         if (set_stun(0)) ident = TRUE;
2500                         if (set_cut(0)) ident = TRUE;
2501                         if (set_shero(0,TRUE)) ident = TRUE;
2502                         break;
2503                 }
2504
2505                 case SV_STAFF_THE_MAGI:
2506                 {
2507                         if (do_res_stat(A_INT)) ident = TRUE;
2508                         if (p_ptr->csp < p_ptr->msp)
2509                         {
2510                                 p_ptr->csp = p_ptr->msp;
2511                                 p_ptr->csp_frac = 0;
2512                                 ident = TRUE;
2513 #ifdef JP
2514                                 msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
2515 #else
2516                                 msg_print("You feel your head clear.");
2517 #endif
2518
2519                                 p_ptr->redraw |= (PR_MANA);
2520                                 p_ptr->window |= (PW_PLAYER);
2521                                 p_ptr->window |= (PW_SPELL);
2522                         }
2523                         if (set_shero(0,TRUE)) ident = TRUE;
2524                         break;
2525                 }
2526
2527                 case SV_STAFF_SLEEP_MONSTERS:
2528                 {
2529                         if (sleep_monsters()) ident = TRUE;
2530                         break;
2531                 }
2532
2533                 case SV_STAFF_SLOW_MONSTERS:
2534                 {
2535                         if (slow_monsters()) ident = TRUE;
2536                         break;
2537                 }
2538
2539                 case SV_STAFF_SPEED:
2540                 {
2541                         if (set_fast(randint1(30) + 15, FALSE)) ident = TRUE;
2542                         break;
2543                 }
2544
2545                 case SV_STAFF_PROBING:
2546                 {
2547                         probing();
2548                         ident = TRUE;
2549                         break;
2550                 }
2551
2552                 case SV_STAFF_DISPEL_EVIL:
2553                 {
2554                         if (dispel_evil(80)) ident = TRUE;
2555                         break;
2556                 }
2557
2558                 case SV_STAFF_POWER:
2559                 {
2560                         if (dispel_monsters(150)) ident = TRUE;
2561                         break;
2562                 }
2563
2564                 case SV_STAFF_HOLINESS:
2565                 {
2566                         if (dispel_evil(150)) ident = TRUE;
2567                         k = 3 * p_ptr->lev;
2568                         if (set_protevil((magic ? 0 : p_ptr->protevil) + randint1(25) + k, FALSE)) ident = TRUE;
2569                         if (set_poisoned(0)) ident = TRUE;
2570                         if (set_afraid(0)) ident = TRUE;
2571                         if (hp_player(50)) ident = TRUE;
2572                         if (set_stun(0)) ident = TRUE;
2573                         if (set_cut(0)) ident = TRUE;
2574                         break;
2575                 }
2576
2577                 case SV_STAFF_GENOCIDE:
2578                 {
2579                         (void)symbol_genocide((magic ? p_ptr->lev + 50 : 200), TRUE);
2580                         ident = TRUE;
2581                         break;
2582                 }
2583
2584                 case SV_STAFF_EARTHQUAKES:
2585                 {
2586                         if (earthquake(py, px, 10))
2587                                 ident = TRUE;
2588                         else
2589 #ifdef JP
2590 msg_print("¥À¥ó¥¸¥ç¥ó¤¬Íɤ줿¡£");
2591 #else
2592                                 msg_print("The dungeon trembles.");
2593 #endif
2594
2595
2596                         break;
2597                 }
2598
2599                 case SV_STAFF_DESTRUCTION:
2600                 {
2601                         if (destroy_area(py, px, 13 + randint0(5), FALSE))
2602                                 ident = TRUE;
2603
2604                         break;
2605                 }
2606
2607                 case SV_STAFF_ANIMATE_DEAD:
2608                 {
2609                         if (animate_dead(0, py, px))
2610                                 ident = TRUE;
2611
2612                         break;
2613                 }
2614
2615                 case SV_STAFF_MSTORM:
2616                 {
2617 #ifdef JP
2618                         msg_print("¶¯ÎϤÊËâÎϤ¬Å¨¤ò°ú¤­Îö¤¤¤¿¡ª");
2619 #else
2620                         msg_print("Mighty magics rend your enemies!");
2621 #endif
2622                         project(0, 5, py, px,
2623                                 (randint1(200) + 300) * 2, GF_MANA, PROJECT_KILL | PROJECT_ITEM | PROJECT_GRID, -1);
2624                         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))
2625                         {
2626 #ifdef JP
2627                                 (void)take_hit(DAMAGE_NOESCAPE, 50, "¥³¥ó¥È¥í¡¼¥ë¤·Æñ¤¤¶¯ÎϤÊËâÎϤβòÊü", -1);
2628 #else
2629                                 (void)take_hit(DAMAGE_NOESCAPE, 50, "unleashing magics too mighty to control", -1);
2630 #endif
2631                         }
2632                         ident = TRUE;
2633
2634                         break;
2635                 }
2636
2637                 case SV_STAFF_NOTHING:
2638                 {
2639 #ifdef JP
2640                         msg_print("²¿¤âµ¯¤é¤Ê¤«¤Ã¤¿¡£");
2641 #else
2642                         msg_print("Nothing happen.");
2643 #endif
2644                         if (prace_is_(RACE_SKELETON) || prace_is_(RACE_GOLEM) ||
2645                                 prace_is_(RACE_ZOMBIE) || prace_is_(RACE_SPECTRE))
2646 #ifdef JP
2647                                 msg_print("¤â¤Ã¤¿¤¤¤Ê¤¤»ö¤ò¤·¤¿¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£¿©¤Ùʪ¤ÏÂçÀڤˤ·¤Ê¤¯¤Æ¤Ï¡£");
2648 #else
2649                                 msg_print("What a waste.  It's your food!");
2650 #endif
2651                         break;
2652                 }
2653         }
2654         return ident;
2655 }
2656
2657 /*
2658  * Use a staff.                 -RAK-
2659  *
2660  * One charge of one staff disappears.
2661  *
2662  * Hack -- staffs of identify can be "cancelled".
2663  */
2664 static void do_cmd_use_staff_aux(int item)
2665 {
2666         int         ident, chance, lev;
2667         object_type *o_ptr;
2668
2669
2670         /* Hack -- let staffs of identify get aborted */
2671         bool use_charge = TRUE;
2672
2673
2674         /* Get the item (in the pack) */
2675         if (item >= 0)
2676         {
2677                 o_ptr = &inventory[item];
2678         }
2679
2680         /* Get the item (on the floor) */
2681         else
2682         {
2683                 o_ptr = &o_list[0 - item];
2684         }
2685
2686
2687         /* Mega-Hack -- refuse to use a pile from the ground */
2688         if ((item < 0) && (o_ptr->number > 1))
2689         {
2690 #ifdef JP
2691                 msg_print("¤Þ¤º¤Ï¾ó¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
2692 #else
2693                 msg_print("You must first pick up the staffs.");
2694 #endif
2695
2696                 return;
2697         }
2698
2699
2700         /* Take a turn */
2701         energy_use = 100;
2702
2703         /* Extract the item level */
2704         lev = k_info[o_ptr->k_idx].level;
2705         if (lev > 50) lev = 50 + (lev - 50)/2;
2706
2707         /* Base chance of success */
2708         chance = p_ptr->skill_dev;
2709
2710         /* Confusion hurts skill */
2711         if (p_ptr->confused) chance = chance / 2;
2712
2713         /* Hight level objects are harder */
2714         chance = chance - lev;
2715
2716         /* Give everyone a (slight) chance */
2717         if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
2718         {
2719                 chance = USE_DEVICE;
2720         }
2721
2722         if (world_player)
2723         {
2724                 if (flush_failure) flush();
2725 #ifdef JP
2726                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
2727 #else
2728                 msg_print("Nothing happen. Maybe this staff is freezing too.");
2729 #endif
2730
2731                 sound(SOUND_FAIL);
2732                 return;
2733         }
2734
2735         /* Roll for usage */
2736         if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
2737         {
2738                 if (flush_failure) flush();
2739 #ifdef JP
2740                 msg_print("¾ó¤ò¤¦¤Þ¤¯»È¤¨¤Ê¤«¤Ã¤¿¡£");
2741 #else
2742                 msg_print("You failed to use the staff properly.");
2743 #endif
2744
2745                 sound(SOUND_FAIL);
2746                 return;
2747         }
2748
2749         /* Notice empty staffs */
2750         if (o_ptr->pval <= 0)
2751         {
2752                 if (flush_failure) flush();
2753 #ifdef JP
2754                 msg_print("¤³¤Î¾ó¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
2755 #else
2756                 msg_print("The staff has no charges left.");
2757 #endif
2758
2759                 o_ptr->ident |= (IDENT_EMPTY);
2760
2761                 /* Combine / Reorder the pack (later) */
2762                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2763                 p_ptr->window |= (PW_INVEN);
2764
2765                 return;
2766         }
2767
2768
2769         /* Sound */
2770         sound(SOUND_ZAP);
2771
2772         ident = staff_effect(o_ptr->sval, &use_charge, FALSE, object_is_aware(o_ptr));
2773
2774         if (!(object_is_aware(o_ptr)))
2775         {
2776                 chg_virtue(V_PATIENCE, -1);
2777                 chg_virtue(V_CHANCE, 1);
2778                 chg_virtue(V_KNOWLEDGE, -1);
2779         }
2780
2781         /* Combine / Reorder the pack (later) */
2782         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
2783
2784         /* Tried the item */
2785         object_tried(o_ptr);
2786
2787         /* An identification was made */
2788         if (ident && !object_is_aware(o_ptr))
2789         {
2790                 object_aware(o_ptr);
2791                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
2792         }
2793
2794         /* Window stuff */
2795         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
2796
2797
2798         /* Hack -- some uses are "free" */
2799         if (!use_charge) return;
2800
2801
2802         /* Use a single charge */
2803         o_ptr->pval--;
2804
2805         /* XXX Hack -- unstack if necessary */
2806         if ((item >= 0) && (o_ptr->number > 1))
2807         {
2808                 object_type forge;
2809                 object_type *q_ptr;
2810
2811                 /* Get local object */
2812                 q_ptr = &forge;
2813
2814                 /* Obtain a local object */
2815                 object_copy(q_ptr, o_ptr);
2816
2817                 /* Modify quantity */
2818                 q_ptr->number = 1;
2819
2820                 /* Restore the charges */
2821                 o_ptr->pval++;
2822
2823                 /* Unstack the used item */
2824                 o_ptr->number--;
2825                 p_ptr->total_weight -= q_ptr->weight;
2826                 item = inven_carry(q_ptr);
2827
2828                 /* Message */
2829 #ifdef JP
2830                 msg_print("¾ó¤ò¤Þ¤È¤á¤Ê¤ª¤·¤¿¡£");
2831 #else
2832                 msg_print("You unstack your staff.");
2833 #endif
2834
2835         }
2836
2837         /* Describe charges in the pack */
2838         if (item >= 0)
2839         {
2840                 inven_item_charges(item);
2841         }
2842
2843         /* Describe charges on the floor */
2844         else
2845         {
2846                 floor_item_charges(0 - item);
2847         }
2848 }
2849
2850
2851 void do_cmd_use_staff(void)
2852 {
2853         int  item;
2854         cptr q, s;
2855
2856         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
2857         {
2858                 set_action(ACTION_NONE);
2859         }
2860
2861         /* Restrict choices to wands */
2862         item_tester_tval = TV_STAFF;
2863
2864         /* Get an item */
2865 #ifdef JP
2866         q = "¤É¤Î¾ó¤ò»È¤¤¤Þ¤¹¤«? ";
2867         s = "»È¤¨¤ë¾ó¤¬¤Ê¤¤¡£";
2868 #else
2869         q = "Use which staff? ";
2870         s = "You have no staff to use.";
2871 #endif
2872
2873         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
2874
2875         do_cmd_use_staff_aux(item);
2876 }
2877
2878
2879 static int wand_effect(int sval, int dir, bool magic)
2880 {
2881         int ident = FALSE;
2882
2883         /* XXX Hack -- Wand of wonder can do anything before it */
2884         if (sval == SV_WAND_WONDER)
2885         {
2886                 int vir = virtue_number(V_CHANCE);
2887                 sval = randint0(SV_WAND_WONDER);
2888
2889                 if (vir)
2890                 {
2891                         if (p_ptr->virtues[vir - 1] > 0)
2892                         {
2893                                 while (randint1(300) < p_ptr->virtues[vir - 1]) sval++;
2894                                 if (sval > SV_WAND_COLD_BALL) sval = randint0(4) + SV_WAND_ACID_BALL;
2895                         }
2896                         else
2897                         {
2898                                 while (randint1(300) < (0-p_ptr->virtues[vir - 1])) sval--;
2899                                 if (sval < SV_WAND_HEAL_MONSTER) sval = randint0(3) + SV_WAND_HEAL_MONSTER;
2900                         }
2901                 }
2902                 if (sval < SV_WAND_TELEPORT_AWAY)
2903                         chg_virtue(V_CHANCE, 1);
2904         }
2905
2906         /* Analyze the wand */
2907         switch (sval)
2908         {
2909                 case SV_WAND_HEAL_MONSTER:
2910                 {
2911                         if (heal_monster(dir, damroll(10, 10))) ident = TRUE;
2912                         break;
2913                 }
2914
2915                 case SV_WAND_HASTE_MONSTER:
2916                 {
2917                         if (speed_monster(dir)) ident = TRUE;
2918                         break;
2919                 }
2920
2921                 case SV_WAND_CLONE_MONSTER:
2922                 {
2923                         if (clone_monster(dir)) ident = TRUE;
2924                         break;
2925                 }
2926
2927                 case SV_WAND_TELEPORT_AWAY:
2928                 {
2929                         if (teleport_monster(dir)) ident = TRUE;
2930                         break;
2931                 }
2932
2933                 case SV_WAND_DISARMING:
2934                 {
2935                         if (disarm_trap(dir)) ident = TRUE;
2936                         break;
2937                 }
2938
2939                 case SV_WAND_TRAP_DOOR_DEST:
2940                 {
2941                         if (destroy_door(dir)) ident = TRUE;
2942                         break;
2943                 }
2944
2945                 case SV_WAND_STONE_TO_MUD:
2946                 {
2947                         if (wall_to_mud(dir)) ident = TRUE;
2948                         break;
2949                 }
2950
2951                 case SV_WAND_LITE:
2952                 {
2953 #ifdef JP
2954                         msg_print("ÀĤ¯µ±¤¯¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
2955 #else
2956                         msg_print("A line of blue shimmering light appears.");
2957 #endif
2958
2959                         (void)lite_line(dir);
2960                         ident = TRUE;
2961                         break;
2962                 }
2963
2964                 case SV_WAND_SLEEP_MONSTER:
2965                 {
2966                         if (sleep_monster(dir)) ident = TRUE;
2967                         break;
2968                 }
2969
2970                 case SV_WAND_SLOW_MONSTER:
2971                 {
2972                         if (slow_monster(dir)) ident = TRUE;
2973                         break;
2974                 }
2975
2976                 case SV_WAND_CONFUSE_MONSTER:
2977                 {
2978                         if (confuse_monster(dir, p_ptr->lev)) ident = TRUE;
2979                         break;
2980                 }
2981
2982                 case SV_WAND_FEAR_MONSTER:
2983                 {
2984                         if (fear_monster(dir, p_ptr->lev)) ident = TRUE;
2985                         break;
2986                 }
2987
2988                 case SV_WAND_DRAIN_LIFE:
2989                 {
2990                         if (drain_life(dir, 80 + p_ptr->lev)) ident = TRUE;
2991                         break;
2992                 }
2993
2994                 case SV_WAND_POLYMORPH:
2995                 {
2996                         if (poly_monster(dir)) ident = TRUE;
2997                         break;
2998                 }
2999
3000                 case SV_WAND_STINKING_CLOUD:
3001                 {
3002                         fire_ball(GF_POIS, dir, 12 + p_ptr->lev / 4, 2);
3003                         ident = TRUE;
3004                         break;
3005                 }
3006
3007                 case SV_WAND_MAGIC_MISSILE:
3008                 {
3009                         fire_bolt_or_beam(20, GF_MISSILE, dir, damroll(2 + p_ptr->lev / 10, 6));
3010                         ident = TRUE;
3011                         break;
3012                 }
3013
3014                 case SV_WAND_ACID_BOLT:
3015                 {
3016                         fire_bolt_or_beam(20, GF_ACID, dir, damroll(6 + p_ptr->lev / 7, 8));
3017                         ident = TRUE;
3018                         break;
3019                 }
3020
3021                 case SV_WAND_CHARM_MONSTER:
3022                 {
3023                         if (charm_monster(dir, MAX(20, p_ptr->lev)))
3024                         ident = TRUE;
3025                         break;
3026                 }
3027
3028                 case SV_WAND_FIRE_BOLT:
3029                 {
3030                         fire_bolt_or_beam(20, GF_FIRE, dir, damroll(7 + p_ptr->lev / 6, 8));
3031                         ident = TRUE;
3032                         break;
3033                 }
3034
3035                 case SV_WAND_COLD_BOLT:
3036                 {
3037                         fire_bolt_or_beam(20, GF_COLD, dir, damroll(5 + p_ptr->lev / 8, 8));
3038                         ident = TRUE;
3039                         break;
3040                 }
3041
3042                 case SV_WAND_ACID_BALL:
3043                 {
3044                         fire_ball(GF_ACID, dir, 60 + 3 * p_ptr->lev / 4, 2);
3045                         ident = TRUE;
3046                         break;
3047                 }
3048
3049                 case SV_WAND_ELEC_BALL:
3050                 {
3051                         fire_ball(GF_ELEC, dir, 40 + 3 * p_ptr->lev / 4, 2);
3052                         ident = TRUE;
3053                         break;
3054                 }
3055
3056                 case SV_WAND_FIRE_BALL:
3057                 {
3058                         fire_ball(GF_FIRE, dir, 70 + 3 * p_ptr->lev / 4, 2);
3059                         ident = TRUE;
3060                         break;
3061                 }
3062
3063                 case SV_WAND_COLD_BALL:
3064                 {
3065                         fire_ball(GF_COLD, dir, 50 + 3 * p_ptr->lev / 4, 2);
3066                         ident = TRUE;
3067                         break;
3068                 }
3069
3070                 case SV_WAND_WONDER:
3071                 {
3072 #ifdef JP
3073                         msg_print("¤ª¤Ã¤È¡¢Ææ¤ÎËâË¡ËÀ¤ò»ÏÆ°¤µ¤»¤¿¡£");
3074 #else
3075                         msg_print("Oops.  Wand of wonder activated.");
3076 #endif
3077
3078                         break;
3079                 }
3080
3081                 case SV_WAND_DRAGON_FIRE:
3082                 {
3083                         fire_ball(GF_FIRE, dir, 200, -3);
3084                         ident = TRUE;
3085                         break;
3086                 }
3087
3088                 case SV_WAND_DRAGON_COLD:
3089                 {
3090                         fire_ball(GF_COLD, dir, 180, -3);
3091                         ident = TRUE;
3092                         break;
3093                 }
3094
3095                 case SV_WAND_DRAGON_BREATH:
3096                 {
3097                         switch (randint1(5))
3098                         {
3099                                 case 1:
3100                                 {
3101                                         fire_ball(GF_ACID, dir, 240, -3);
3102                                         break;
3103                                 }
3104
3105                                 case 2:
3106                                 {
3107                                         fire_ball(GF_ELEC, dir, 210, -3);
3108                                         break;
3109                                 }
3110
3111                                 case 3:
3112                                 {
3113                                         fire_ball(GF_FIRE, dir, 240, -3);
3114                                         break;
3115                                 }
3116
3117                                 case 4:
3118                                 {
3119                                         fire_ball(GF_COLD, dir, 210, -3);
3120                                         break;
3121                                 }
3122
3123                                 default:
3124                                 {
3125                                         fire_ball(GF_POIS, dir, 180, -3);
3126                                         break;
3127                                 }
3128                         }
3129
3130                         ident = TRUE;
3131                         break;
3132                 }
3133
3134                 case SV_WAND_DISINTEGRATE:
3135                 {
3136                         fire_ball(GF_DISINTEGRATE, dir, 200 + randint1(p_ptr->lev * 2), 2);
3137                         ident = TRUE;
3138                         break;
3139                 }
3140
3141                 case SV_WAND_ROCKETS:
3142                 {
3143 #ifdef JP
3144 msg_print("¥í¥±¥Ã¥È¤òȯ¼Í¤·¤¿¡ª");
3145 #else
3146                         msg_print("You launch a rocket!");
3147 #endif
3148
3149                         fire_rocket(GF_ROCKET, dir, 250 + p_ptr->lev * 3, 2);
3150                         ident = TRUE;
3151                         break;
3152                 }
3153
3154                 case SV_WAND_STRIKING:
3155                 {
3156                         fire_bolt(GF_METEOR, dir, damroll(15 + p_ptr->lev / 3, 13));
3157                         ident = TRUE;
3158                         break;
3159                 }
3160
3161                 case SV_WAND_GENOCIDE:
3162                 {
3163                         fire_ball_hide(GF_GENOCIDE, dir, magic ? p_ptr->lev + 50 : 250, 0);
3164                         ident = TRUE;
3165                         break;
3166                 }
3167         }
3168         return ident;
3169 }
3170
3171
3172 /*
3173  * Aim a wand (from the pack or floor).
3174  *
3175  * Use a single charge from a single item.
3176  * Handle "unstacking" in a logical manner.
3177  *
3178  * For simplicity, you cannot use a stack of items from the
3179  * ground.  This would require too much nasty code.
3180  *
3181  * There are no wands which can "destroy" themselves, in the inventory
3182  * or on the ground, so we can ignore this possibility.  Note that this
3183  * required giving "wand of wonder" the ability to ignore destruction
3184  * by electric balls.
3185  *
3186  * All wands can be "cancelled" at the "Direction?" prompt for free.
3187  *
3188  * Note that the basic "bolt" wands do slightly less damage than the
3189  * basic "bolt" rods, but the basic "ball" wands do the same damage
3190  * as the basic "ball" rods.
3191  */
3192 static void do_cmd_aim_wand_aux(int item)
3193 {
3194         int         lev, ident, chance, dir;
3195         object_type *o_ptr;
3196         bool old_target_pet = target_pet;
3197
3198         /* Get the item (in the pack) */
3199         if (item >= 0)
3200         {
3201                 o_ptr = &inventory[item];
3202         }
3203
3204         /* Get the item (on the floor) */
3205         else
3206         {
3207                 o_ptr = &o_list[0 - item];
3208         }
3209
3210         /* Mega-Hack -- refuse to aim a pile from the ground */
3211         if ((item < 0) && (o_ptr->number > 1))
3212         {
3213 #ifdef JP
3214                 msg_print("¤Þ¤º¤ÏËâË¡ËÀ¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
3215 #else
3216                 msg_print("You must first pick up the wands.");
3217 #endif
3218
3219                 return;
3220         }
3221
3222
3223         /* Allow direction to be cancelled for free */
3224         if (object_is_aware(o_ptr) && (o_ptr->sval == SV_WAND_HEAL_MONSTER
3225                                       || o_ptr->sval == SV_WAND_HASTE_MONSTER))
3226                         target_pet = TRUE;
3227         if (!get_aim_dir(&dir))
3228         {
3229                 target_pet = old_target_pet;
3230                 return;
3231         }
3232         target_pet = old_target_pet;
3233
3234         /* Take a turn */
3235         energy_use = 100;
3236
3237         /* Get the level */
3238         lev = k_info[o_ptr->k_idx].level;
3239         if (lev > 50) lev = 50 + (lev - 50)/2;
3240
3241         /* Base chance of success */
3242         chance = p_ptr->skill_dev;
3243
3244         /* Confusion hurts skill */
3245         if (p_ptr->confused) chance = chance / 2;
3246
3247         /* Hight level objects are harder */
3248         chance = chance - lev;
3249
3250         /* Give everyone a (slight) chance */
3251         if ((chance < USE_DEVICE) && one_in_(USE_DEVICE - chance + 1))
3252         {
3253                 chance = USE_DEVICE;
3254         }
3255
3256         if (world_player)
3257         {
3258                 if (flush_failure) flush();
3259 #ifdef JP
3260                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
3261 #else
3262                 msg_print("Nothing happen. Maybe this wand is freezing too.");
3263 #endif
3264
3265                 sound(SOUND_FAIL);
3266                 return;
3267         }
3268
3269         /* Roll for usage */
3270         if ((chance < USE_DEVICE) || (randint1(chance) < USE_DEVICE) || (p_ptr->pclass == CLASS_BERSERKER))
3271         {
3272                 if (flush_failure) flush();
3273 #ifdef JP
3274                 msg_print("ËâË¡ËÀ¤ò¤¦¤Þ¤¯»È¤¨¤Ê¤«¤Ã¤¿¡£");
3275 #else
3276                 msg_print("You failed to use the wand properly.");
3277 #endif
3278
3279                 sound(SOUND_FAIL);
3280                 return;
3281         }
3282
3283         /* The wand is already empty! */
3284         if (o_ptr->pval <= 0)
3285         {
3286                 if (flush_failure) flush();
3287 #ifdef JP
3288                 msg_print("¤³¤ÎËâË¡ËÀ¤Ë¤Ï¤â¤¦ËâÎϤ¬»Ä¤Ã¤Æ¤¤¤Ê¤¤¡£");
3289 #else
3290                 msg_print("The wand has no charges left.");
3291 #endif
3292
3293                 o_ptr->ident |= (IDENT_EMPTY);
3294
3295                 /* Combine / Reorder the pack (later) */
3296                 p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3297                 p_ptr->window |= (PW_INVEN);
3298
3299                 return;
3300         }
3301
3302         /* Sound */
3303         sound(SOUND_ZAP);
3304
3305         ident = wand_effect(o_ptr->sval, dir, FALSE);
3306
3307         /* Combine / Reorder the pack (later) */
3308         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3309
3310         if (!(object_is_aware(o_ptr)))
3311         {
3312                 chg_virtue(V_PATIENCE, -1);
3313                 chg_virtue(V_CHANCE, 1);
3314                 chg_virtue(V_KNOWLEDGE, -1);
3315         }
3316
3317         /* Mark it as tried */
3318         object_tried(o_ptr);
3319
3320         /* Apply identification */
3321         if (ident && !object_is_aware(o_ptr))
3322         {
3323                 object_aware(o_ptr);
3324                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
3325         }
3326
3327         /* Window stuff */
3328         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
3329
3330
3331         /* Use a single charge */
3332         o_ptr->pval--;
3333
3334         /* Describe the charges in the pack */
3335         if (item >= 0)
3336         {
3337                 inven_item_charges(item);
3338         }
3339
3340         /* Describe the charges on the floor */
3341         else
3342         {
3343                 floor_item_charges(0 - item);
3344         }
3345 }
3346
3347
3348 void do_cmd_aim_wand(void)
3349 {
3350         int     item;
3351         cptr    q, s;
3352
3353         /* Restrict choices to wands */
3354         item_tester_tval = TV_WAND;
3355
3356         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
3357         {
3358                 set_action(ACTION_NONE);
3359         }
3360
3361         /* Get an item */
3362 #ifdef JP
3363         q = "¤É¤ÎËâË¡ËÀ¤ÇÁÀ¤¤¤Þ¤¹¤«? ";
3364         s = "»È¤¨¤ëËâË¡ËÀ¤¬¤Ê¤¤¡£";
3365 #else
3366         q = "Aim which wand? ";
3367         s = "You have no wand to aim.";
3368 #endif
3369
3370         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
3371
3372         /* Aim the wand */
3373         do_cmd_aim_wand_aux(item);
3374 }
3375
3376
3377 static int rod_effect(int sval, int dir, bool *use_charge, bool magic)
3378 {
3379         int ident = FALSE;
3380
3381         /* Unused */
3382         (void)magic;
3383
3384         /* Analyze the rod */
3385         switch (sval)
3386         {
3387                 case SV_ROD_DETECT_TRAP:
3388                 {
3389                         if (detect_traps(DETECT_RAD_DEFAULT, (bool)(dir ? FALSE : TRUE))) ident = TRUE;
3390                         break;
3391                 }
3392
3393                 case SV_ROD_DETECT_DOOR:
3394                 {
3395                         if (detect_doors(DETECT_RAD_DEFAULT)) ident = TRUE;
3396                         if (detect_stairs(DETECT_RAD_DEFAULT)) ident = TRUE;
3397                         break;
3398                 }
3399
3400                 case SV_ROD_IDENTIFY:
3401                 {
3402                         if (!ident_spell(FALSE)) *use_charge = FALSE;
3403                         ident = TRUE;
3404                         break;
3405                 }
3406
3407                 case SV_ROD_RECALL:
3408                 {
3409                         if (!word_of_recall()) *use_charge = FALSE;
3410                         ident = TRUE;
3411                         break;
3412                 }
3413
3414                 case SV_ROD_ILLUMINATION:
3415                 {
3416                         if (lite_area(damroll(2, 8), 2)) ident = TRUE;
3417                         break;
3418                 }
3419
3420                 case SV_ROD_MAPPING:
3421                 {
3422                         map_area(DETECT_RAD_MAP);
3423                         ident = TRUE;
3424                         break;
3425                 }
3426
3427                 case SV_ROD_DETECTION:
3428                 {
3429                         detect_all(DETECT_RAD_DEFAULT);
3430                         ident = TRUE;
3431                         break;
3432                 }
3433
3434                 case SV_ROD_PROBING:
3435                 {
3436                         probing();
3437                         ident = TRUE;
3438                         break;
3439                 }
3440
3441                 case SV_ROD_CURING:
3442                 {
3443                         if (set_blind(0)) ident = TRUE;
3444                         if (set_poisoned(0)) ident = TRUE;
3445                         if (set_confused(0)) ident = TRUE;
3446                         if (set_stun(0)) ident = TRUE;
3447                         if (set_cut(0)) ident = TRUE;
3448                         if (set_image(0)) ident = TRUE;
3449                         if (set_shero(0,TRUE)) ident = TRUE;
3450                         break;
3451                 }
3452
3453                 case SV_ROD_HEALING:
3454                 {
3455                         if (hp_player(500)) ident = TRUE;
3456                         if (set_stun(0)) ident = TRUE;
3457                         if (set_cut(0)) ident = TRUE;
3458                         if (set_shero(0,TRUE)) ident = TRUE;
3459                         break;
3460                 }
3461
3462                 case SV_ROD_RESTORATION:
3463                 {
3464                         if (restore_level()) ident = TRUE;
3465                         if (do_res_stat(A_STR)) ident = TRUE;
3466                         if (do_res_stat(A_INT)) ident = TRUE;
3467                         if (do_res_stat(A_WIS)) ident = TRUE;
3468                         if (do_res_stat(A_DEX)) ident = TRUE;
3469                         if (do_res_stat(A_CON)) ident = TRUE;
3470                         if (do_res_stat(A_CHR)) ident = TRUE;
3471                         break;
3472                 }
3473
3474                 case SV_ROD_SPEED:
3475                 {
3476                         if (set_fast(randint1(30) + 15, FALSE)) ident = TRUE;
3477                         break;
3478                 }
3479
3480                 case SV_ROD_PESTICIDE:
3481                 {
3482                         if (dispel_monsters(4)) ident = TRUE;
3483                         break;
3484                 }
3485
3486                 case SV_ROD_TELEPORT_AWAY:
3487                 {
3488                         if (teleport_monster(dir)) ident = TRUE;
3489                         break;
3490                 }
3491
3492                 case SV_ROD_DISARMING:
3493                 {
3494                         if (disarm_trap(dir)) ident = TRUE;
3495                         break;
3496                 }
3497
3498                 case SV_ROD_LITE:
3499                 {
3500 #ifdef JP
3501                         msg_print("ÀĤ¯µ±¤¯¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
3502 #else
3503                         msg_print("A line of blue shimmering light appears.");
3504 #endif
3505
3506                         (void)lite_line(dir);
3507                         ident = TRUE;
3508                         break;
3509                 }
3510
3511                 case SV_ROD_SLEEP_MONSTER:
3512                 {
3513                         if (sleep_monster(dir)) ident = TRUE;
3514                         break;
3515                 }
3516
3517                 case SV_ROD_SLOW_MONSTER:
3518                 {
3519                         if (slow_monster(dir)) ident = TRUE;
3520                         break;
3521                 }
3522
3523                 case SV_ROD_DRAIN_LIFE:
3524                 {
3525                         if (drain_life(dir, 70 + 3 * p_ptr->lev / 2)) ident = TRUE;
3526                         break;
3527                 }
3528
3529                 case SV_ROD_POLYMORPH:
3530                 {
3531                         if (poly_monster(dir)) ident = TRUE;
3532                         break;
3533                 }
3534
3535                 case SV_ROD_ACID_BOLT:
3536                 {
3537                         fire_bolt_or_beam(10, GF_ACID, dir, damroll(6 + p_ptr->lev / 7, 8));
3538                         ident = TRUE;
3539                         break;
3540                 }
3541
3542                 case SV_ROD_ELEC_BOLT:
3543                 {
3544                         fire_bolt_or_beam(10, GF_ELEC, dir, damroll(4 + p_ptr->lev / 9, 8));
3545                         ident = TRUE;
3546                         break;
3547                 }
3548
3549                 case SV_ROD_FIRE_BOLT:
3550                 {
3551                         fire_bolt_or_beam(10, GF_FIRE, dir, damroll(7 + p_ptr->lev / 6, 8));
3552                         ident = TRUE;
3553                         break;
3554                 }
3555
3556                 case SV_ROD_COLD_BOLT:
3557                 {
3558                         fire_bolt_or_beam(10, GF_COLD, dir, damroll(5 + p_ptr->lev / 8, 8));
3559                         ident = TRUE;
3560                         break;
3561                 }
3562
3563                 case SV_ROD_ACID_BALL:
3564                 {
3565                         fire_ball(GF_ACID, dir, 60 + p_ptr->lev, 2);
3566                         ident = TRUE;
3567                         break;
3568                 }
3569
3570                 case SV_ROD_ELEC_BALL:
3571                 {
3572                         fire_ball(GF_ELEC, dir, 40 + p_ptr->lev, 2);
3573                         ident = TRUE;
3574                         break;
3575                 }
3576
3577                 case SV_ROD_FIRE_BALL:
3578                 {
3579                         fire_ball(GF_FIRE, dir, 70 + p_ptr->lev, 2);
3580                         ident = TRUE;
3581                         break;
3582                 }
3583
3584                 case SV_ROD_COLD_BALL:
3585                 {
3586                         fire_ball(GF_COLD, dir, 50 + p_ptr->lev, 2);
3587                         ident = TRUE;
3588                         break;
3589                 }
3590
3591                 case SV_ROD_HAVOC:
3592                 {
3593                         call_chaos();
3594                         ident = TRUE;
3595                         break;
3596                 }
3597
3598                 case SV_ROD_STONE_TO_MUD:
3599                 {
3600                         if (wall_to_mud(dir)) ident = TRUE;
3601                         break;
3602                 }
3603
3604                 case SV_ROD_AGGRAVATE:
3605                 {
3606                         aggravate_monsters(0);
3607                         ident = TRUE;
3608                         break;
3609                 }
3610         }
3611         return ident;
3612 }
3613
3614 /*
3615  * Activate (zap) a Rod
3616  *
3617  * Unstack fully charged rods as needed.
3618  *
3619  * Hack -- rods of perception/genocide can be "cancelled"
3620  * All rods can be cancelled at the "Direction?" prompt
3621  *
3622  * pvals are defined for each rod in k_info. -LM-
3623  */
3624 static void do_cmd_zap_rod_aux(int item)
3625 {
3626         int ident, chance, lev, fail;
3627         int dir = 0;
3628         object_type *o_ptr;
3629         bool success;
3630
3631         /* Hack -- let perception get aborted */
3632         bool use_charge = TRUE;
3633
3634         object_kind *k_ptr;
3635
3636         /* Get the item (in the pack) */
3637         if (item >= 0)
3638         {
3639                 o_ptr = &inventory[item];
3640         }
3641
3642         /* Get the item (on the floor) */
3643         else
3644         {
3645                 o_ptr = &o_list[0 - item];
3646         }
3647
3648
3649         /* Mega-Hack -- refuse to zap a pile from the ground */
3650         if ((item < 0) && (o_ptr->number > 1))
3651         {
3652 #ifdef JP
3653                 msg_print("¤Þ¤º¤Ï¥í¥Ã¥É¤ò½¦¤ï¤Ê¤±¤ì¤Ð¡£");
3654 #else
3655                 msg_print("You must first pick up the rods.");
3656 #endif
3657
3658                 return;
3659         }
3660
3661
3662         /* Get a direction (unless KNOWN not to need it) */
3663         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)) ||
3664              !object_is_aware(o_ptr))
3665         {
3666                 /* Get a direction, allow cancel */
3667                 if (!get_aim_dir(&dir)) return;
3668         }
3669
3670
3671         /* Take a turn */
3672         energy_use = 100;
3673
3674         /* Extract the item level */
3675         lev = k_info[o_ptr->k_idx].level;
3676
3677         /* Base chance of success */
3678         chance = p_ptr->skill_dev;
3679
3680         /* Confusion hurts skill */
3681         if (p_ptr->confused) chance = chance / 2;
3682
3683         fail = lev+5;
3684         if (chance > fail) fail -= (chance - fail)*2;
3685         else chance -= (fail - chance)*2;
3686         if (fail < USE_DEVICE) fail = USE_DEVICE;
3687         if (chance < USE_DEVICE) chance = USE_DEVICE;
3688
3689         if (world_player)
3690         {
3691                 if (flush_failure) flush();
3692 #ifdef JP
3693                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
3694 #else
3695                 msg_print("Nothing happen. Maybe this rod is freezing too.");
3696 #endif
3697
3698                 sound(SOUND_FAIL);
3699                 return;
3700         }
3701
3702         if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
3703         else if (chance > fail)
3704         {
3705                 if (randint0(chance*2) < fail) success = FALSE;
3706                 else success = TRUE;
3707         }
3708         else
3709         {
3710                 if (randint0(fail*2) < chance) success = TRUE;
3711                 else success = FALSE;
3712         }
3713
3714         /* Roll for usage */
3715         if (!success)
3716         {
3717                 if (flush_failure) flush();
3718 #ifdef JP
3719                 msg_print("¤¦¤Þ¤¯¥í¥Ã¥É¤ò»È¤¨¤Ê¤«¤Ã¤¿¡£");
3720 #else
3721                 msg_print("You failed to use the rod properly.");
3722 #endif
3723
3724                 sound(SOUND_FAIL);
3725                 return;
3726         }
3727
3728         k_ptr = &k_info[o_ptr->k_idx];
3729
3730         /* A single rod is still charging */
3731         if ((o_ptr->number == 1) && (o_ptr->timeout))
3732         {
3733                 if (flush_failure) flush();
3734 #ifdef JP
3735                 msg_print("¤³¤Î¥í¥Ã¥É¤Ï¤Þ¤ÀËâÎϤò½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
3736 #else
3737                 msg_print("The rod is still charging.");
3738 #endif
3739
3740                 return;
3741         }
3742         /* A stack of rods lacks enough energy. */
3743         else if ((o_ptr->number > 1) && (o_ptr->timeout > k_ptr->pval * (o_ptr->number - 1)))
3744         {
3745                 if (flush_failure) flush();
3746 #ifdef JP
3747 msg_print("¤½¤Î¥í¥Ã¥É¤Ï¤Þ¤À½¼Å¶Ãæ¤Ç¤¹¡£");
3748 #else
3749                 msg_print("The rods are all still charging.");
3750 #endif
3751
3752                 return;
3753         }
3754
3755         /* Sound */
3756         sound(SOUND_ZAP);
3757
3758         ident = rod_effect(o_ptr->sval, dir, &use_charge, FALSE);
3759
3760         /* Increase the timeout by the rod kind's pval. -LM- */
3761         if (use_charge) o_ptr->timeout += k_ptr->pval;
3762
3763         /* Combine / Reorder the pack (later) */
3764         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
3765
3766         if (!(object_is_aware(o_ptr)))
3767         {
3768                 chg_virtue(V_PATIENCE, -1);
3769                 chg_virtue(V_CHANCE, 1);
3770                 chg_virtue(V_KNOWLEDGE, -1);
3771         }
3772
3773         /* Tried the object */
3774         object_tried(o_ptr);
3775
3776         /* Successfully determined the object function */
3777         if (ident && !object_is_aware(o_ptr))
3778         {
3779                 object_aware(o_ptr);
3780                 gain_exp((lev + (p_ptr->lev >> 1)) / p_ptr->lev);
3781         }
3782
3783         /* Window stuff */
3784         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
3785 }
3786
3787
3788 void do_cmd_zap_rod(void)
3789 {
3790         int item;
3791         cptr q, s;
3792
3793         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
3794         {
3795                 set_action(ACTION_NONE);
3796         }
3797
3798         /* Restrict choices to rods */
3799         item_tester_tval = TV_ROD;
3800
3801         /* Get an item */
3802 #ifdef JP
3803         q = "¤É¤Î¥í¥Ã¥É¤ò¿¶¤ê¤Þ¤¹¤«? ";
3804         s = "»È¤¨¤ë¥í¥Ã¥É¤¬¤Ê¤¤¡£";
3805 #else
3806         q = "Zap which rod? ";
3807         s = "You have no rod to zap.";
3808 #endif
3809
3810         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
3811
3812         /* Zap the rod */
3813         do_cmd_zap_rod_aux(item);
3814 }
3815
3816
3817 /*
3818  * Hook to determine if an object is activatable
3819  */
3820 static bool item_tester_hook_activate(object_type *o_ptr)
3821 {
3822         u32b flgs[TR_FLAG_SIZE];
3823
3824         /* Not known */
3825         if (!object_is_known(o_ptr)) return (FALSE);
3826
3827         /* Extract the flags */
3828         object_flags(o_ptr, flgs);
3829
3830         /* Check activation flag */
3831         if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
3832
3833         /* Assume not */
3834         return (FALSE);
3835 }
3836
3837
3838 /*
3839  * Hack -- activate the ring of power
3840  */
3841 void ring_of_power(int dir)
3842 {
3843         /* Pick a random effect */
3844         switch (randint1(10))
3845         {
3846                 case 1:
3847                 case 2:
3848                 {
3849                         /* Message */
3850 #ifdef JP
3851                         msg_print("¤¢¤Ê¤¿¤Ï°­À­¤Î¥ª¡¼¥é¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡£");
3852 #else
3853                         msg_print("You are surrounded by a malignant aura.");
3854 #endif
3855
3856                         sound(SOUND_EVIL);
3857
3858                         /* Decrease all stats (permanently) */
3859                         (void)dec_stat(A_STR, 50, TRUE);
3860                         (void)dec_stat(A_INT, 50, TRUE);
3861                         (void)dec_stat(A_WIS, 50, TRUE);
3862                         (void)dec_stat(A_DEX, 50, TRUE);
3863                         (void)dec_stat(A_CON, 50, TRUE);
3864                         (void)dec_stat(A_CHR, 50, TRUE);
3865
3866                         /* Lose some experience (permanently) */
3867                         p_ptr->exp -= (p_ptr->exp / 4);
3868                         p_ptr->max_exp -= (p_ptr->exp / 4);
3869                         check_experience();
3870
3871                         break;
3872                 }
3873
3874                 case 3:
3875                 {
3876                         /* Message */
3877 #ifdef JP
3878                         msg_print("¤¢¤Ê¤¿¤Ï¶¯ÎϤʥª¡¼¥é¤ËÊñ¤ß¹þ¤Þ¤ì¤¿¡£");
3879 #else
3880                         msg_print("You are surrounded by a powerful aura.");
3881 #endif
3882
3883
3884                         /* Dispel monsters */
3885                         dispel_monsters(1000);
3886
3887                         break;
3888                 }
3889
3890                 case 4:
3891                 case 5:
3892                 case 6:
3893                 {
3894                         /* Mana Ball */
3895                         fire_ball(GF_MANA, dir, 600, 3);
3896
3897                         break;
3898                 }
3899
3900                 case 7:
3901                 case 8:
3902                 case 9:
3903                 case 10:
3904                 {
3905                         /* Mana Bolt */
3906                         fire_bolt(GF_MANA, dir, 500);
3907
3908                         break;
3909                 }
3910         }
3911 }
3912
3913
3914 static bool ang_sort_comp_pet(vptr u, vptr v, int a, int b)
3915 {
3916         u16b *who = (u16b*)(u);
3917
3918         int w1 = who[a];
3919         int w2 = who[b];
3920
3921         monster_type *m_ptr1 = &m_list[w1];
3922         monster_type *m_ptr2 = &m_list[w2];
3923         monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
3924         monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
3925
3926         /* Unused */
3927         (void)v;
3928
3929         if (m_ptr1->nickname && !m_ptr2->nickname) return TRUE;
3930         if (m_ptr2->nickname && !m_ptr1->nickname) return FALSE;
3931
3932         if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return TRUE;
3933         if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return FALSE;
3934
3935         if (r_ptr1->level > r_ptr2->level) return TRUE;
3936         if (r_ptr2->level > r_ptr1->level) return FALSE;
3937
3938         if (m_ptr1->hp > m_ptr2->hp) return TRUE;
3939         if (m_ptr2->hp > m_ptr1->hp) return FALSE;
3940         
3941         return w1 <= w2;
3942 }
3943
3944 /*
3945  * Activate a wielded object.  Wielded objects never stack.
3946  * And even if they did, activatable objects never stack.
3947  *
3948  * Currently, only (some) artifacts, and Dragon Scale Mail, can be activated.
3949  * But one could, for example, easily make an activatable "Ring of Plasma".
3950  *
3951  * Note that it always takes a turn to activate an artifact, even if
3952  * the user hits "escape" at the "direction" prompt.
3953  */
3954 static void do_cmd_activate_aux(int item)
3955 {
3956         int         k, dir, lev, chance, fail;
3957         object_type *o_ptr;
3958         bool success;
3959
3960
3961         /* Get the item (in the pack) */
3962         if (item >= 0)
3963         {
3964                 o_ptr = &inventory[item];
3965         }
3966
3967         /* Get the item (on the floor) */
3968         else
3969         {
3970                 o_ptr = &o_list[0 - item];
3971         }
3972
3973         /* Take a turn */
3974         energy_use = 100;
3975
3976         /* Extract the item level */
3977         lev = k_info[o_ptr->k_idx].level;
3978
3979         /* Hack -- use artifact level instead */
3980         if (object_is_fixed_artifact(o_ptr)) lev = a_info[o_ptr->name1].level;
3981         else if (o_ptr->art_name)
3982         {
3983                 switch (o_ptr->xtra2)
3984                 {
3985                         case ACT_SUNLIGHT:
3986                         case ACT_BO_MISS_1:
3987                         case ACT_BA_POIS_1:
3988                         case ACT_CONFUSE:
3989                         case ACT_SLEEP:
3990                         case ACT_CURE_LW:
3991                         case ACT_CURE_POISON:
3992                         case ACT_BERSERK:
3993                         case ACT_LIGHT:
3994                         case ACT_DEST_DOOR:
3995                         case ACT_TELEPORT:
3996                                 lev = 10;
3997                                 break;
3998                         case ACT_BO_ELEC_1:
3999                         case ACT_BO_ACID_1:
4000                         case ACT_BO_COLD_1:
4001                         case ACT_BO_FIRE_1:
4002                         case ACT_MAP_LIGHT:
4003                         case ACT_STONE_MUD:
4004                         case ACT_CURE_MW:
4005                         case ACT_QUAKE:
4006                                 lev = 20;
4007                                 break;
4008                         case ACT_DRAIN_1:
4009                         case ACT_TELE_AWAY:
4010                         case ACT_ESP:
4011                         case ACT_RESIST_ALL:
4012                         case ACT_DETECT_ALL:
4013                         case ACT_RECALL:
4014                         case ACT_SATIATE:
4015                         case ACT_RECHARGE:
4016                                 lev = 30;
4017                                 break;
4018                         case ACT_BA_COLD_1:
4019                         case ACT_BA_FIRE_1:
4020                         case ACT_TERROR:
4021                         case ACT_PROT_EVIL:
4022                         case ACT_ID_PLAIN:
4023                         case ACT_REST_LIFE:
4024                         case ACT_SPEED:
4025                         case ACT_BANISH_EVIL:
4026                                 lev = 40;
4027                                 break;
4028                         case ACT_DRAIN_2:
4029                         case ACT_VAMPIRE_1:
4030                         case ACT_BO_MISS_2:
4031                         case ACT_BA_FIRE_2:
4032                         case ACT_WHIRLWIND:
4033                         case ACT_CHARM_ANIMAL:
4034                         case ACT_SUMMON_ANIMAL:
4035                         case ACT_DISP_EVIL:
4036                         case ACT_DISP_GOOD:
4037                         case ACT_XTRA_SPEED:
4038                         case ACT_DETECT_XTRA:
4039                         case ACT_ID_FULL:
4040                                 lev = 50;
4041                                 break;
4042                         case ACT_VAMPIRE_2:
4043                         case ACT_BA_COLD_3:
4044                         case ACT_BA_ELEC_3:
4045                         case ACT_GENOCIDE:
4046                         case ACT_CHARM_UNDEAD:
4047                         case ACT_CHARM_OTHER:
4048                         case ACT_SUMMON_PHANTOM:
4049                         case ACT_SUMMON_ELEMENTAL:
4050                         case ACT_RUNE_EXPLO:
4051                                 lev = 60;
4052                                 break;
4053                         case ACT_MASS_GENO:
4054                         case ACT_CHARM_ANIMALS:
4055                         case ACT_CHARM_OTHERS:
4056                         case ACT_CURE_700:
4057                         case ACT_RUNE_PROT:
4058                         case ACT_ALCHEMY:
4059                         case ACT_REST_ALL:
4060                                 lev = 70;
4061                                 break;
4062                         case ACT_CALL_CHAOS:
4063                         case ACT_ROCKET:
4064                         case ACT_BA_MISS_3:
4065                         case ACT_CURE_1000:
4066                         case ACT_DIM_DOOR:
4067                         case ACT_SUMMON_UNDEAD:
4068                         case ACT_SUMMON_DEMON:
4069                                 lev = 80;
4070                                 break;
4071                         case ACT_WRAITH:
4072                         case ACT_INVULN:
4073                                 lev = 100;
4074                                 break;
4075                         default:
4076                                 lev = 0;
4077                 }
4078         }
4079         else if (((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET)) && o_ptr->name2) lev = e_info[o_ptr->name2].level;
4080
4081         /* Base chance of success */
4082         chance = p_ptr->skill_dev;
4083
4084         /* Confusion hurts skill */
4085         if (p_ptr->confused) chance = chance / 2;
4086
4087         fail = lev+5;
4088         if (chance > fail) fail -= (chance - fail)*2;
4089         else chance -= (fail - chance)*2;
4090         if (fail < USE_DEVICE) fail = USE_DEVICE;
4091         if (chance < USE_DEVICE) chance = USE_DEVICE;
4092
4093         if (world_player)
4094         {
4095                 if (flush_failure) flush();
4096 #ifdef JP
4097                 msg_print("»ß¤Þ¤Ã¤¿»þ¤ÎÃæ¤Ç¤Ï¤¦¤Þ¤¯Æ¯¤«¤Ê¤¤¤è¤¦¤À¡£");
4098 #else
4099                 msg_print("It shows no reaction.");
4100 #endif
4101
4102                 sound(SOUND_FAIL);
4103                 return;
4104         }
4105
4106         if (p_ptr->pclass == CLASS_BERSERKER) success = FALSE;
4107         else if (chance > fail)
4108         {
4109                 if (randint0(chance*2) < fail) success = FALSE;
4110                 else success = TRUE;
4111         }
4112         else
4113         {
4114                 if (randint0(fail*2) < chance) success = TRUE;
4115                 else success = FALSE;
4116         }
4117
4118         /* Roll for usage */
4119         if (!success)
4120         {
4121                 if (flush_failure) flush();
4122 #ifdef JP
4123                 msg_print("¤¦¤Þ¤¯»ÏÆ°¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤Ê¤«¤Ã¤¿¡£");
4124 #else
4125                 msg_print("You failed to activate it properly.");
4126 #endif
4127
4128                 sound(SOUND_FAIL);
4129                 return;
4130         }
4131
4132         /* Check the recharge */
4133         if (o_ptr->timeout)
4134         {
4135 #ifdef JP
4136                 msg_print("¤½¤ì¤ÏÈù¤«¤Ë²»¤òΩ¤Æ¡¢µ±¤­¡¢¾Ã¤¨¤¿...");
4137 #else
4138                 msg_print("It whines, glows and fades...");
4139 #endif
4140
4141                 return;
4142         }
4143
4144
4145         /* Activate the artifact */
4146 #ifdef JP
4147         msg_print("»ÏÆ°¤µ¤»¤¿...");
4148 #else
4149         msg_print("You activate it...");
4150 #endif
4151
4152
4153         /* Sound */
4154         sound(SOUND_ZAP);
4155
4156
4157         if (o_ptr->art_name && o_ptr->xtra2)
4158         {
4159                 (void)activate_random_artifact(o_ptr);
4160
4161                 /* Window stuff */
4162                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
4163
4164                 /* Success */
4165                 return;
4166         }
4167
4168         /* Artifacts */
4169         else if (object_is_fixed_artifact(o_ptr))
4170         {
4171                 /* Choose effect */
4172                 switch (o_ptr->name1)
4173                 {
4174                         case ART_GALADRIEL:
4175                         {
4176 #ifdef JP
4177                                 msg_print("ààÍþÉÓ¤«¤éÀ¡¤ó¤À¸÷¤¬¤¢¤Õ¤ì½Ð¤¿...");
4178 #else
4179                                 msg_print("The phial wells with clear light...");
4180 #endif
4181
4182                                 lite_area(damroll(2, 15), 3);
4183                                 o_ptr->timeout = randint0(10) + 10;
4184                                 break;
4185                         }
4186
4187                         case ART_ELENDIL:
4188                         {
4189 #ifdef JP
4190                                 msg_print("À±¤¬âÁ¤·¤¯µ±¤¤¤¿...");
4191 #else
4192                                 msg_print("The star shines brightly...");
4193 #endif
4194
4195                                 map_area(DETECT_RAD_MAP);
4196                                 lite_area(damroll(2, 15), 3);
4197                                 o_ptr->timeout = randint0(50) + 50;
4198                                 break;
4199                         }
4200
4201                         case ART_JUDGE:
4202                         {
4203 #ifdef JP
4204 msg_print("¤½¤ÎÊõÀФÏÀÖ¤¯ÌÀ¤ë¤¯¸÷¤Ã¤¿¡ª");
4205 #else
4206                                 msg_print("The Jewel flashes bright red!");
4207 #endif
4208
4209                                 chg_virtue(V_KNOWLEDGE, 1);
4210                                 chg_virtue(V_ENLIGHTEN, 1);
4211                                 wiz_lite(FALSE);
4212 #ifdef JP
4213 msg_print("¤½¤ÎÊõÀФϤ¢¤Ê¤¿¤ÎÂÎÎϤòÃ¥¤Ã¤¿...");
4214 take_hit(DAMAGE_LOSELIFE, damroll(3,8), "¿³È½¤ÎÊõÀÐ", -1);
4215 #else
4216                                 msg_print("The Jewel drains your vitality...");
4217                                 take_hit(DAMAGE_LOSELIFE, damroll(3, 8), "the Jewel of Judgement", -1);
4218 #endif
4219
4220                                 (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
4221                                 (void)detect_doors(DETECT_RAD_DEFAULT);
4222                                 (void)detect_stairs(DETECT_RAD_DEFAULT);
4223
4224 #ifdef JP
4225 if (get_check("µ¢´Ô¤ÎÎϤò»È¤¤¤Þ¤¹¤«¡©"))
4226 #else
4227                                 if (get_check("Activate recall? "))
4228 #endif
4229
4230                                 {
4231                                         (void)word_of_recall();
4232                                 }
4233
4234                                 o_ptr->timeout = randint0(20) + 20;
4235                                 break;
4236                         }
4237
4238                         case ART_CARLAMMAS:
4239                         {
4240 #ifdef JP
4241                                 msg_print("¥¢¥ß¥å¥ì¥Ã¥È¤«¤é±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
4242 #else
4243                                 msg_print("The amulet lets out a shrill wail...");
4244 #endif
4245
4246                                 k = 3 * p_ptr->lev;
4247                                 (void)set_protevil(randint1(25) + k, FALSE);
4248                                 o_ptr->timeout = randint0(225) + 225;
4249                                 break;
4250                         }
4251
4252                         case ART_INGWE:
4253                         {
4254 #ifdef JP
4255                                 msg_print("¥¢¥ß¥å¥ì¥Ã¥È¤ÏÊÕ¤ê¤òÁ±¤Î¥ª¡¼¥é¤ÇËþ¤¿¤·¤¿...");
4256 #else
4257                                 msg_print("The amulet floods the area with goodness...");
4258 #endif
4259
4260                                 dispel_evil(p_ptr->lev * 5);
4261                                 o_ptr->timeout = randint0(200) + 200;
4262                                 break;
4263                         }
4264
4265                         case ART_YATA:
4266                         {
4267 #ifdef JP
4268                                 msg_print("¶À¤ÏÊÕ¤ê¤òÁ±¤Î¥ª¡¼¥é¤ÇËþ¤¿¤·¤¿...");
4269 #else
4270                                 msg_print("The mirror floods the area with goodness...");
4271 #endif
4272
4273                                 dispel_evil(p_ptr->lev * 5);
4274                                 o_ptr->timeout = randint0(200) + 200;
4275                                 break;
4276                         }
4277
4278                         case ART_FRAKIR:
4279                         {
4280 #ifdef JP
4281 msg_print("¤¢¤Ê¤¿¤Ï¥Õ¥é¥­¥¢¤ËŨ¤òÄù¤á»¦¤¹¤è¤¦Ì¿¤¸¤¿¡£");
4282 #else
4283                                 msg_print("You order Frakir to strangle your opponent.");
4284 #endif
4285
4286                                 if (!get_aim_dir(&dir)) return;
4287                                 if (drain_life(dir, 100))
4288                                 o_ptr->timeout = randint0(100) + 100;
4289                                 break;
4290                         }
4291
4292                         case ART_TULKAS:
4293                         {
4294 #ifdef JP
4295                                 msg_print("»ØÎؤÏÌÀ¤ë¤¯µ±¤¤¤¿...");
4296 #else
4297                                 msg_print("The ring glows brightly...");
4298 #endif
4299
4300                                 (void)set_fast(randint1(75) + 75, FALSE);
4301                                 o_ptr->timeout = randint0(150) + 150;
4302                                 break;
4303                         }
4304
4305                         case ART_NARYA:
4306                         {
4307 #ifdef JP
4308                                 msg_print("»ØÎؤϿ¼¹È¤Ëµ±¤¤¤¿...");
4309 #else
4310                                 msg_print("The ring glows deep red...");
4311 #endif
4312
4313                                 if (!get_aim_dir(&dir)) return;
4314                                 fire_ball(GF_FIRE, dir, 300, 3);
4315                                 o_ptr->timeout = randint0(225) + 225;
4316                                 break;
4317                         }
4318
4319                         case ART_NENYA:
4320                         {
4321 #ifdef JP
4322                                 msg_print("»ØÎؤÏÇò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4323 #else
4324                                 msg_print("The ring glows bright white...");
4325 #endif
4326
4327                                 if (!get_aim_dir(&dir)) return;
4328                                 fire_ball(GF_COLD, dir, 400, 3);
4329                                 o_ptr->timeout = randint0(325) + 325;
4330                                 break;
4331                         }
4332
4333                         case ART_VILYA:
4334                         case ART_GOURYU:
4335                         {
4336 #ifdef JP
4337                                 msg_format("%s¤Ï¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...", o_ptr->name1 == ART_VILYA ? "»ØÎØ" : "¥½¡¼¥É");
4338 #else
4339                                 msg_format("The %s glows deep blue...", o_ptr->name1 == ART_VILYA ? "ring" : "sword");
4340 #endif
4341
4342                                 if (!get_aim_dir(&dir)) return;
4343                                 fire_ball(GF_ELEC, dir, 500, 3);
4344                                 o_ptr->timeout = randint0(425) + 425;
4345                                 break;
4346                         }
4347
4348                         case ART_POWER:
4349                         case ART_AHO:
4350                         {
4351 #ifdef JP
4352                                 msg_print("»ØÎؤϼ¿¹õ¤Ëµ±¤¤¤¿...");
4353 #else
4354                                 msg_print("The ring glows intensely black...");
4355 #endif
4356
4357                                 if (!get_aim_dir(&dir)) return;
4358                                 ring_of_power(dir);
4359                                 o_ptr->timeout = randint0(450) + 450;
4360                                 break;
4361                         }
4362
4363                         case ART_RAZORBACK:
4364                         {
4365                                 int num = damroll(5, 3);
4366                                 int y, x;
4367                                 int attempts;
4368
4369 #ifdef JP
4370                                 msg_print("³»¤¬°ðºÊ¤Çʤ¤ï¤ì¤¿...");
4371 #else
4372                                 msg_print("Your armor is surrounded by lightning...");
4373 #endif
4374
4375
4376                                 for (k = 0; k < num; k++)
4377                                 {
4378                                         attempts = 1000;
4379
4380                                         while (attempts--)
4381                                         {
4382                                                 scatter(&y, &x, py, px, 4, 0);
4383
4384                                                 if (!cave_have_flag_bold(y, x, FF_PROJECT)) continue;
4385
4386                                                 if (!player_bold(y, x)) break;
4387                                         }
4388
4389                                         project(0, 3, y, x, 150, GF_ELEC,
4390                                                           (PROJECT_THRU | PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1);
4391                                 }
4392
4393                                 o_ptr->timeout = 1000;
4394                                 break;
4395                         }
4396
4397                         case ART_BLADETURNER:
4398                         {
4399                                 if (!get_aim_dir(&dir)) return;
4400 #ifdef JP
4401                                 msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
4402 #else
4403                                 msg_print("You breathe the elements.");
4404 #endif
4405
4406                                 fire_ball(GF_MISSILE, dir, 300, 4);
4407 #ifdef JP
4408                                 msg_print("³»¤¬ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤¿...");
4409 #else
4410                                 msg_print("Your armor glows many colours...");
4411 #endif
4412
4413                                 (void)set_afraid(0);
4414                                 (void)set_hero(randint1(50) + 50, FALSE);
4415                                 (void)hp_player(10);
4416                                 (void)set_blessed(randint1(50) + 50, FALSE);
4417                                 (void)set_oppose_acid(randint1(50) + 50, FALSE);
4418                                 (void)set_oppose_elec(randint1(50) + 50, FALSE);
4419                                 (void)set_oppose_fire(randint1(50) + 50, FALSE);
4420                                 (void)set_oppose_cold(randint1(50) + 50, FALSE);
4421                                 (void)set_oppose_pois(randint1(50) + 50, FALSE);
4422                                 o_ptr->timeout = 400;
4423                                 break;
4424                         }
4425
4426                         case ART_SOULKEEPER:
4427                         {
4428 #ifdef JP
4429                                 msg_print("³»¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4430                                 msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬¤è¤¤...");
4431 #else
4432                                 msg_print("Your armor glows a bright white...");
4433                                 msg_print("You feel much better...");
4434 #endif
4435
4436                                 (void)hp_player(1000);
4437                                 (void)set_cut(0);
4438                                 o_ptr->timeout = 888;
4439                                 break;
4440                         }
4441
4442                         case ART_LOHENGRIN:
4443                         {
4444 #ifdef JP
4445 msg_print("Å·¹ñ¤Î²Î¤¬Ê¹¤³¤¨¤ë...");
4446 #else
4447                                 msg_print("A heavenly choir sings...");
4448 #endif
4449
4450                                 (void)set_poisoned(0);
4451                                 (void)set_cut(0);
4452                                 (void)set_stun(0);
4453                                 (void)set_confused(0);
4454                                 (void)set_blind(0);
4455                                 (void)set_afraid(0);
4456                                 (void)set_hero(randint1(25) + 25, FALSE);
4457                                 (void)hp_player(777);
4458                                 o_ptr->timeout = 300;
4459                                 break;
4460                         }
4461
4462                         case ART_JULIAN:
4463                         {
4464 #ifdef JP
4465                                 msg_print("³»¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4466 #else
4467                                 msg_print("Your armor glows deep blue...");
4468 #endif
4469
4470                                 (void)symbol_genocide(200, TRUE);
4471                                 o_ptr->timeout = 500;
4472                                 break;
4473                         }
4474
4475                         case ART_CASPANION:
4476                         {
4477 #ifdef JP
4478                                 msg_print("³»¤¬ÀÖ¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4479 #else
4480                                 msg_print("Your armor glows bright red...");
4481 #endif
4482
4483                                 destroy_doors_touch();
4484                                 o_ptr->timeout = 10;
4485                                 break;
4486                         }
4487
4488                         case ART_DOR:
4489                         case ART_TERROR:
4490                         case ART_STONEMASK:
4491                         {
4492                                 turn_monsters(40 + p_ptr->lev);
4493                                 o_ptr->timeout = 3 * (p_ptr->lev + 10);
4494
4495                                 break;
4496                         }
4497
4498                         case ART_HOLHENNETH:
4499                         {
4500 #ifdef JP
4501                                 msg_print("¥Ø¥ë¥á¥Ã¥È¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4502                                 msg_print("¿´¤Ë¥¤¥á¡¼¥¸¤¬É⤫¤ó¤Ç¤­¤¿...");
4503 #else
4504                                 msg_print("Your helm glows bright white...");
4505                                 msg_print("An image forms in your mind...");
4506 #endif
4507
4508                                 detect_all(DETECT_RAD_DEFAULT);
4509                                 o_ptr->timeout = randint0(55) + 55;
4510                                 break;
4511                         }
4512
4513                         case ART_AMBER:
4514                         {
4515 #ifdef JP
4516                                 msg_print("²¦´§¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4517                                 msg_print("ÂÎÆâ¤ËÃȤ«¤¤¸ÝÆ°¤¬´¶¤¸¤é¤ì¤ë...");
4518 #else
4519                                 msg_print("Your crown glows deep blue...");
4520                                 msg_print("You feel a warm tingling inside...");
4521 #endif
4522
4523                                 (void)hp_player(700);
4524                                 (void)set_cut(0);
4525                                 o_ptr->timeout = 250;
4526                                 break;
4527                         }
4528
4529                         case ART_COLLUIN:
4530                         case ART_SEIRYU:
4531                         {
4532 #ifdef JP
4533                                 msg_format("%s¤¬ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤¿...", o_ptr->name1 == ART_COLLUIN ? "¥¯¥í¡¼¥¯" : "³»");
4534 #else
4535                                 msg_format("Your %s glows many colours...", o_ptr->name1 == ART_COLLUIN ? "cloak" : "armor");
4536 #endif
4537
4538                                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
4539                                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
4540                                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
4541                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
4542                                 (void)set_oppose_pois(randint1(20) + 20, FALSE);
4543                                 o_ptr->timeout = 111;
4544                                 break;
4545                         }
4546
4547                         case ART_HOLCOLLETH:
4548                         {
4549 #ifdef JP
4550                                 msg_print("¥¯¥í¡¼¥¯¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4551 #else
4552                                 msg_print("Your cloak glows deep blue...");
4553 #endif
4554
4555                                 sleep_monsters_touch();
4556                                 o_ptr->timeout = 55;
4557                                 break;
4558                         }
4559
4560                         case ART_THINGOL:
4561                         {
4562 #ifdef JP
4563                                 msg_print("¥¯¥í¡¼¥¯¤¬²«¿§¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4564 #else
4565                                 msg_print("Your cloak glows bright yellow...");
4566 #endif
4567
4568                                 recharge(130);
4569                                 o_ptr->timeout = 70;
4570                                 break;
4571                         }
4572
4573                         case ART_COLANNON:
4574                         {
4575 #ifdef JP
4576                                 msg_print("¥¯¥í¡¼¥¯¤¬ÊÕ¤ê¤Î¶õ´Ö¤ò¤æ¤¬¤Þ¤»¤¿...");
4577 #else
4578                                 msg_print("Your cloak twists space around you...");
4579 #endif
4580
4581                                 teleport_player(100, 0L);
4582                                 o_ptr->timeout = 45;
4583                                 break;
4584                         }
4585
4586                         case ART_LUTHIEN:
4587                         {
4588 #ifdef JP
4589                                 msg_print("¥¯¥í¡¼¥¯¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
4590 #else
4591                                 msg_print("Your cloak glows a deep red...");
4592 #endif
4593
4594                                 restore_level();
4595                                 o_ptr->timeout = 450;
4596                                 break;
4597                         }
4598
4599                         case ART_HEAVENLY_MAIDEN:
4600                         {
4601 #ifdef JP
4602                                 msg_print("¥¯¥í¡¼¥¯¤¬½À¤é¤«¤¯Çò¤¯µ±¤¤¤¿...");
4603 #else
4604                                 msg_print("Your cloak glows soft white...");
4605 #endif
4606                                 if (!word_of_recall()) return;
4607                                 o_ptr->timeout = 200;
4608                                 break;
4609                         }
4610
4611                         case ART_CAMMITHRIM:
4612                         {
4613 #ifdef JP
4614                                 msg_print("¥°¥í¡¼¥Ö¤¬âÁ¤·¤¤¤¯¤é¤¤¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
4615 #else
4616                                 msg_print("Your gloves glow extremely brightly...");
4617 #endif
4618
4619                                 if (!get_aim_dir(&dir)) return;
4620                                 fire_bolt(GF_MISSILE, dir, damroll(2, 6));
4621                                 o_ptr->timeout = 2;
4622                                 break;
4623                         }
4624
4625                         case ART_PAURHACH:
4626                         {
4627 #ifdef JP
4628                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬±ê¤Ëʤ¤ï¤ì¤¿...");
4629 #else
4630                                 msg_print("Your gauntlets are covered in fire...");
4631 #endif
4632
4633                                 if (!get_aim_dir(&dir)) return;
4634                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
4635                                 o_ptr->timeout = randint0(8) + 8;
4636                                 break;
4637                         }
4638
4639                         case ART_PAURNIMMEN:
4640                         {
4641 #ifdef JP
4642                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4643 #else
4644                                 msg_print("Your gauntlets are covered in frost...");
4645 #endif
4646
4647                                 if (!get_aim_dir(&dir)) return;
4648                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
4649                                 o_ptr->timeout = randint0(7) + 7;
4650                                 break;
4651                         }
4652
4653                         case ART_PAURAEGEN:
4654                         {
4655 #ifdef JP
4656                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬²Ð²Ö¤Ëʤ¤ï¤ì¤¿...");
4657 #else
4658                                 msg_print("Your gauntlets are covered in sparks...");
4659 #endif
4660
4661                                 if (!get_aim_dir(&dir)) return;
4662                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
4663                                 o_ptr->timeout = randint0(5) + 5;
4664                                 break;
4665                         }
4666
4667                         case ART_PAURNEN:
4668                         {
4669 #ifdef JP
4670                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬»À¤Ëʤ¤ï¤ì¤¿...");
4671 #else
4672                                 msg_print("Your gauntlets are covered in acid...");
4673 #endif
4674
4675                                 if (!get_aim_dir(&dir)) return;
4676                                 fire_bolt(GF_ACID, dir, damroll(5, 8));
4677                                 o_ptr->timeout = randint0(6) + 6;
4678                                 break;
4679                         }
4680
4681                         case ART_FINGOLFIN:
4682                         {
4683 #ifdef JP
4684                                 msg_print("¥»¥¹¥¿¥¹¤ËËâË¡¤Î¥È¥²¤¬¸½¤ì¤¿...");
4685 #else
4686                                 msg_print("Your cesti grows magical spikes...");
4687 #endif
4688
4689                                 if (!get_aim_dir(&dir)) return;
4690                                 fire_bolt(GF_ARROW, dir, 150);
4691                                 o_ptr->timeout = randint0(90) + 90;
4692                                 break;
4693                         }
4694
4695                         case ART_FEANOR:
4696                         {
4697 #ifdef JP
4698                                 msg_print("¥Ö¡¼¥Ä¤¬¥°¥ê¡¼¥ó¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
4699 #else
4700                                 msg_print("Your boots glow bright green...");
4701 #endif
4702
4703                                 (void)set_fast(randint1(20) + 20, FALSE);
4704                                 o_ptr->timeout = 200;
4705                                 break;
4706                         }
4707
4708                         case ART_FLORA:
4709                         {
4710 #ifdef JP
4711                                 msg_print("¥Ö¡¼¥Ä¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4712 #else
4713                                 msg_print("Your boots glow deep blue...");
4714 #endif
4715
4716                                 (void)set_afraid(0);
4717                                 (void)set_poisoned(0);
4718                                 o_ptr->timeout = 5;
4719                                 break;
4720                         }
4721
4722                         case ART_NARTHANC:
4723                         {
4724 #ifdef JP
4725                                 msg_print("¥À¥¬¡¼¤¬±ê¤Ëʤ¤ï¤ì¤¿...");
4726 #else
4727                                 msg_print("Your dagger is covered in fire...");
4728 #endif
4729
4730                                 if (!get_aim_dir(&dir)) return;
4731                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
4732                                 o_ptr->timeout = randint0(8) + 8;
4733                                 break;
4734                         }
4735
4736                         case ART_NIMTHANC:
4737                         {
4738 #ifdef JP
4739                                 msg_print("¥À¥¬¡¼¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4740 #else
4741                                 msg_print("Your dagger is covered in frost...");
4742 #endif
4743
4744                                 if (!get_aim_dir(&dir)) return;
4745                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
4746                                 o_ptr->timeout = randint0(7) + 7;
4747                                 break;
4748                         }
4749
4750                         case ART_DETHANC:
4751                         {
4752 #ifdef JP
4753                                 msg_print("¥À¥¬¡¼¤¬²Ð²Ö¤Ëʤ¤ï¤ì¤¿...");
4754 #else
4755                                 msg_print("Your dagger is covered in sparks...");
4756 #endif
4757
4758                                 if (!get_aim_dir(&dir)) return;
4759                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
4760                                 o_ptr->timeout = randint0(5) + 5;
4761                                 break;
4762                         }
4763
4764                         case ART_RILIA:
4765                         {
4766 #ifdef JP
4767                                 msg_print("¥À¥¬¡¼¤¬¿¼¤¤Îп§¤Ë¸ÝÆ°¤·¤Æ¤¤¤ë...");
4768 #else
4769                                 msg_print("Your dagger throbs deep green...");
4770 #endif
4771
4772                                 if (!get_aim_dir(&dir)) return;
4773                                 fire_ball(GF_POIS, dir, 12, 3);
4774                                 o_ptr->timeout = randint0(4) + 4;
4775                                 break;
4776                         }
4777
4778                         case ART_NUMAHOKO:
4779                         {
4780 #ifdef JP
4781                                 msg_print("Ì·¤¬¿¼¤¤ÀÄ¿§¤Ë¸ÝÆ°¤·¤Æ¤¤¤ë...");
4782 #else
4783                                 msg_print("Your dagger throbs deep blue...");
4784 #endif
4785
4786                                 if (!get_aim_dir(&dir)) return;
4787                                 fire_ball(GF_WATER, dir, 200, 3);
4788                                 o_ptr->timeout = 250;
4789                                 break;
4790                         }
4791
4792                         case ART_FIONA:
4793                         {
4794 #ifdef JP
4795                                 msg_print("¥À¥¬¡¼¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4796 #else
4797                                 msg_print("Your dagger is covered in frost...");
4798 #endif
4799
4800                                 if (!get_aim_dir(&dir)) return;
4801                                 fire_ball(GF_COLD, dir, 48, 2);
4802                                 o_ptr->timeout = randint0(5) + 5;
4803                                 break;
4804                         }
4805
4806                         case ART_KUSANAGI:
4807                         case ART_WEREWINDLE:
4808                         {
4809                                 switch (randint1(13))
4810                                 {
4811                                 case 1: case 2: case 3: case 4: case 5:
4812                                         teleport_player(10, 0L);
4813                                         break;
4814                                 case 6: case 7: case 8: case 9: case 10:
4815                                         teleport_player(222, 0L);
4816                                         break;
4817                                 case 11: case 12:
4818                                         (void)stair_creation();
4819                                         break;
4820                                 default:
4821 #ifdef JP
4822 if (get_check("¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
4823 #else
4824                                         if (get_check("Leave this level? "))
4825 #endif
4826
4827                                         {
4828                                                 if (autosave_l) do_cmd_save_game(TRUE);
4829
4830                                                 /* Leaving */
4831                                                 p_ptr->leaving = TRUE;
4832                                         }
4833                                 }
4834                                 o_ptr->timeout = 35;
4835                                 break;
4836                         }
4837
4838                         case ART_KAMUI:
4839                         {
4840                                 teleport_player(222, 0L);
4841                                 o_ptr->timeout = 25;
4842                                 break;
4843                         }
4844
4845                         case ART_RINGIL:
4846                         {
4847 #ifdef JP
4848                                 msg_print("¥½¡¼¥É¤¬ÀĤ¯·ã¤·¤¯µ±¤¤¤¿...");
4849 #else
4850                                 msg_print("Your sword glows an intense blue...");
4851 #endif
4852
4853                                 if (!get_aim_dir(&dir)) return;
4854                                 fire_ball(GF_COLD, dir, 100, 2);
4855                                 o_ptr->timeout = 200;
4856                                 break;
4857                         }
4858
4859                         case ART_DAWN:
4860                         {
4861 #ifdef JP
4862 msg_print("¶Ç¤Î»ÕÃĤò¾¤´­¤·¤¿¡£");
4863 #else
4864                                 msg_print("You summon the Legion of the Dawn.");
4865 #endif
4866
4867                                 (void)summon_specific(-1, py, px, dun_level, SUMMON_DAWN, (PM_ALLOW_GROUP | PM_FORCE_PET));
4868                                 o_ptr->timeout = 500 + randint1(500);
4869                                 break;
4870                         }
4871
4872                         case ART_ANDURIL:
4873                         {
4874 #ifdef JP
4875                                 msg_print("¥½¡¼¥É¤¬ÀÖ¤¯·ã¤·¤¯µ±¤¤¤¿...");
4876 #else
4877                                 msg_print("Your sword glows an intense red...");
4878 #endif
4879
4880                                 if (!get_aim_dir(&dir)) return;
4881                                 fire_ball(GF_FIRE, dir, 72, 2);
4882                                 o_ptr->timeout = 400;
4883                                 break;
4884                         }
4885
4886                         case ART_THEODEN:
4887                         {
4888 #ifdef JP
4889                                  msg_print("¥¢¥Ã¥¯¥¹¤Î¿Ï¤¬¹õ¤¯µ±¤¤¤¿...");
4890 #else
4891                                 msg_print("Your axe blade glows black...");
4892 #endif
4893
4894                                 if (!get_aim_dir(&dir)) return;
4895                                 drain_life(dir, 120);
4896                                 o_ptr->timeout = 400;
4897                                 break;
4898                         }
4899
4900                         case ART_RUNESPEAR:
4901                         {
4902 #ifdef JP
4903 msg_print("¤¢¤Ê¤¿¤ÎÁä¤ÏÅŵ¤¤Ç¥¹¥Ñ¡¼¥¯¤·¤Æ¤¤¤ë...");
4904 #else
4905                                 msg_print("Your spear crackles with electricity...");
4906 #endif
4907
4908                                 if (!get_aim_dir(&dir)) return;
4909                                 fire_ball(GF_ELEC, dir, 100, 3);
4910                                 o_ptr->timeout = 200;
4911                                 break;
4912                         }
4913
4914                         case ART_AEGLOS:
4915                         {
4916 #ifdef JP
4917                                 msg_print("¥¹¥Ô¥¢¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4918 #else
4919                                 msg_print("Your spear glows a bright white...");
4920 #endif
4921
4922                                 if (!get_aim_dir(&dir)) return;
4923                                 fire_ball(GF_COLD, dir, 100, 3);
4924                                 o_ptr->timeout = 200;
4925                                 break;
4926                         }
4927
4928                         case ART_DESTINY:
4929                         {
4930 #ifdef JP
4931                                 msg_print("¥¹¥Ô¥¢¤¬¸ÝÆ°¤·¤¿...");
4932 #else
4933                                 msg_print("Your spear pulsates...");
4934 #endif
4935
4936                                 if (!get_aim_dir(&dir)) return;
4937                                 wall_to_mud(dir);
4938                                 o_ptr->timeout = 5;
4939                                 break;
4940                         }
4941
4942                         case ART_NAIN:
4943                         {
4944 #ifdef JP
4945                                 msg_print("¤Ä¤ë¤Ï¤·¤¬¸ÝÆ°¤·¤¿...");
4946 #else
4947                                 msg_print("Your mattock pulsates...");
4948 #endif
4949
4950                                 if (!get_aim_dir(&dir)) return;
4951                                 wall_to_mud(dir);
4952                                 o_ptr->timeout = 2;
4953                                 break;
4954                         }
4955
4956                         case ART_EONWE:
4957                         {
4958 #ifdef JP
4959                                 msg_print("¥¢¥Ã¥¯¥¹¤«¤é¤Ò¤É¤¯±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
4960 #else
4961                                 msg_print("Your axe lets out a long, shrill note...");
4962 #endif
4963
4964                                 (void)mass_genocide(200, TRUE);
4965                                 o_ptr->timeout = 1000;
4966                                 break;
4967                         }
4968
4969                         case ART_LOTHARANG:
4970                         {
4971 #ifdef JP
4972                                 msg_print("¥Ð¥È¥ë¡¦¥¢¥Ã¥¯¥¹¤¬¿¼»ç¤Î¸÷¤òÊü¼Í¤·¤¿...");
4973 #else
4974                                 msg_print("Your battle axe radiates deep purple...");
4975 #endif
4976
4977                                 hp_player(damroll(4, 8));
4978                                 (void)set_cut((p_ptr->cut / 2) - 50);
4979                                 o_ptr->timeout = randint0(3) + 3;
4980                                 break;
4981                         }
4982
4983                         case ART_ULMO:
4984                         {
4985 #ifdef JP
4986                                 msg_print("¥È¥é¥¤¥Ç¥ó¥È¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
4987 #else
4988                                 msg_print("Your trident glows deep red...");
4989 #endif
4990
4991                                 if (!get_aim_dir(&dir)) return;
4992                                 teleport_monster(dir);
4993                                 o_ptr->timeout = 150;
4994                                 break;
4995                         }
4996
4997                         case ART_AVAVIR:
4998                         {
4999 #ifdef JP
5000                                 msg_print("Âç³ù¤¬½À¤é¤«¤¯Çò¤¯µ±¤¤¤¿...");
5001 #else
5002                                 msg_print("Your scythe glows soft white...");
5003 #endif
5004                                 if (!word_of_recall()) return;
5005                                 o_ptr->timeout = 200;
5006                                 break;
5007                         }
5008
5009                         case ART_MAGATAMA:
5010                         {
5011 #ifdef JP
5012                                 msg_print("¸û¶Ì¤¬½À¤é¤«¤¯Çò¤¯µ±¤¤¤¿...");
5013 #else
5014                                 msg_print("Your scythe glows soft white...");
5015 #endif
5016                                 if (!word_of_recall()) return;
5017                                 o_ptr->timeout = 200;
5018                                 break;
5019                         }
5020
5021                         case ART_TOTILA:
5022                         {
5023 #ifdef JP
5024                                 msg_print("¥Õ¥ì¥¤¥ë¤¬ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤¿...");
5025 #else
5026                                 msg_print("Your flail glows in scintillating colours...");
5027 #endif
5028
5029                                 if (!get_aim_dir(&dir)) return;
5030                                 confuse_monster(dir, 20);
5031                                 o_ptr->timeout = 15;
5032                                 break;
5033                         }
5034
5035                         case ART_FIRESTAR:
5036                         {
5037 #ifdef JP
5038                                 msg_print("¥â¡¼¥Ë¥ó¥°¥¹¥¿¡¼¤«¤é±ê¤¬¿á¤­½Ð¤·¤¿...");
5039 #else
5040                                 msg_print("Your morning star rages in fire...");
5041 #endif
5042
5043                                 if (!get_aim_dir(&dir)) return;
5044                                 fire_ball(GF_FIRE, dir, 72, 3);
5045                                 o_ptr->timeout = 100;
5046                                 break;
5047                         }
5048
5049                         case ART_GOTHMOG:
5050                         {
5051 #ifdef JP
5052                                 msg_print("¥à¥Á¤¬¿¼¤¤ÀÖ¿§¤Ëµ±¤¤¤¿...");
5053 #else
5054                                 msg_print("Your whip glows deep red...");
5055 #endif
5056
5057                                 if (!get_aim_dir(&dir)) return;
5058                                 fire_ball(GF_FIRE, dir, 120, 3);
5059                                 o_ptr->timeout = 15;
5060                                 break;
5061                         }
5062
5063                         case ART_TARATOL:
5064                         {
5065 #ifdef JP
5066                                 msg_print("¥á¥¤¥¹¤¬¥°¥ê¡¼¥ó¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
5067 #else
5068                                 msg_print("Your mace glows bright green...");
5069 #endif
5070
5071                                 (void)set_fast(randint1(20) + 20, FALSE);
5072                                 o_ptr->timeout = randint0(100) + 100;
5073                                 break;
5074                         }
5075
5076                         case ART_ERIRIL:
5077                         {
5078 #ifdef JP
5079                                 msg_print("¥¯¥©¡¼¥¿¡¼¥¹¥¿¥Ã¥Õ¤¬²«¿§¤¯µ±¤¤¤¿...");
5080 #else
5081                                 msg_print("Your quarterstaff glows yellow...");
5082 #endif
5083
5084                                 if (!ident_spell(FALSE)) return;
5085                                 o_ptr->timeout = 10;
5086                                 break;
5087                         }
5088
5089                         case ART_GANDALF:
5090                         {
5091 #ifdef JP
5092                                 msg_print("¾ó¤¬ÌÀ¤ë¤¯µ±¤¤¤¿...");
5093 #else
5094                                 msg_print("Your quarterstaff glows brightly...");
5095 #endif
5096
5097                                 detect_all(DETECT_RAD_DEFAULT);
5098                                 probing();
5099                                 identify_fully(FALSE);
5100                                 o_ptr->timeout = 100;
5101                                 break;
5102                         }
5103
5104                         case ART_TURMIL:
5105                         {
5106 #ifdef JP
5107                                 msg_print("¥Ï¥ó¥Þ¡¼¤¬Çò¤¯µ±¤¤¤¿...");
5108 #else
5109                                 msg_print("Your hammer glows white...");
5110 #endif
5111
5112                                 if (!get_aim_dir(&dir)) return;
5113                                 drain_life(dir, 90);
5114                                 o_ptr->timeout = 70;
5115                                 break;
5116                         }
5117
5118                         case ART_BRAND:
5119                         case ART_HELLFIRE:
5120                         {
5121 #ifdef JP
5122                                 msg_print("¥¯¥í¥¹¥Ü¥¦¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
5123 #else
5124                                 msg_print("Your crossbow glows deep red...");
5125 #endif
5126
5127                                 (void)brand_bolts();
5128                                 o_ptr->timeout = 999;
5129                                 break;
5130                         }
5131                         case ART_CRIMSON:
5132                         {
5133                                 int num = 1;
5134                                 int i;
5135                                 int flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
5136                                 int tx, ty;
5137 #ifdef JP
5138                                 msg_print("¤»¤Ã¤«¤¯¤À¤«¤é¡Ø¥¯¥ê¥à¥¾¥ó¡Ù¤ò¤Ö¤Ã¤Ñ¤Ê¤¹¤¼¡ª");
5139 #else
5140                                 msg_print("I'll fire CRIMSON! SEKKAKUDAKARA!");
5141 #endif
5142
5143                                 if (!get_aim_dir(&dir)) return;
5144
5145                                 /* Use the given direction */
5146                                 tx = px + 99 * ddx[dir];
5147                                 ty = py + 99 * ddy[dir];
5148
5149                                 /* Hack -- Use an actual "target" */
5150                                 if ((dir == 5) && target_okay())
5151                                 {
5152                                         tx = target_col;
5153                                         ty = target_row;
5154                                 }
5155
5156                                 if (p_ptr->pclass == CLASS_ARCHER)
5157                                 {
5158                                         /* Extra shot at level 10 */
5159                                         if (p_ptr->lev >= 10) num++;
5160
5161                                         /* Extra shot at level 30 */
5162                                         if (p_ptr->lev >= 30) num++;
5163
5164                                         /* Extra shot at level 45 */
5165                                         if (p_ptr->lev >= 45) num++;
5166                                 }
5167
5168                                 for (i = 0; i < num; i++)
5169                                         project(0, p_ptr->lev/20+1, ty, tx, p_ptr->lev*p_ptr->lev*6/50, GF_ROCKET, flg, -1);
5170                                 o_ptr->timeout = 15;
5171                                 break;
5172                         }
5173                         case ART_PALANTIR:
5174                         {
5175                                 monster_type *m_ptr;
5176                                 monster_race *r_ptr;
5177                                 int i;
5178
5179 #ifdef JP
5180                                 msg_print("´ñ̯¤Ê¾ì½ê¤¬Æ¬¤ÎÃæ¤ËÉ⤫¤ó¤À¡¥¡¥¡¥");
5181 #else
5182                                 msg_print("Some strange places show up in your mind. And you see ...");
5183 #endif
5184
5185                                 /* Process the monsters (backwards) */
5186                                 for (i = m_max - 1; i >= 1; i--)
5187                                 {
5188                                         /* Access the monster */
5189                                         m_ptr = &m_list[i];
5190
5191                                         /* Ignore "dead" monsters */
5192                                         if (!m_ptr->r_idx) continue;
5193
5194                                         r_ptr = &r_info[m_ptr->r_idx];
5195
5196                                         if(r_ptr->flags1 & RF1_UNIQUE)
5197                                         {
5198 #ifdef JP
5199                                                 msg_format("%s¡¥ ",r_name + r_ptr->name);
5200 #else
5201                                                 msg_format("%s. ",r_name + r_ptr->name);
5202 #endif
5203                                         }
5204                                 }
5205                                 o_ptr->timeout = 200;
5206                                 break;
5207                         }
5208
5209                         case ART_STONE_LORE:
5210                         {
5211 #ifdef JP
5212                                 msg_print("ÀФ¬±£¤µ¤ì¤¿ÈëÌ©¤ò¼Ì¤·½Ð¤·¤¿¡¥¡¥¡¥");
5213 #else
5214                                 msg_print("The stone reveals hidden mysteries...");
5215 #endif
5216                                 if (!ident_spell(FALSE)) return;
5217
5218                                 if (mp_ptr->spell_book)
5219                                 {
5220                                         /* Sufficient mana */
5221                                         if (20 <= p_ptr->csp)
5222                                         {
5223                                                 /* Use some mana */
5224                                                 p_ptr->csp -= 20;
5225                                         }
5226
5227                                         /* Over-exert the player */
5228                                         else
5229                                         {
5230                                                 int oops = 20 - p_ptr->csp;
5231
5232                                                 /* No mana left */
5233                                                 p_ptr->csp = 0;
5234                                                 p_ptr->csp_frac = 0;
5235
5236                                                 /* Message */
5237 #ifdef JP
5238                                                 msg_print("ÀФòÀ©¸æ¤Ç¤­¤Ê¤¤¡ª");
5239 #else
5240                                                 msg_print("You are too weak to control the stone!");
5241 #endif
5242
5243                                                 /* Hack -- Bypass free action */
5244                                                 (void)set_paralyzed(p_ptr->paralyzed +
5245                                                         randint1(5 * oops + 1));
5246
5247                                                 /* Confusing. */
5248                                                 (void)set_confused(p_ptr->confused +
5249                                                         randint1(5 * oops + 1));
5250                                         }
5251
5252                                         /* Redraw mana */
5253                                         p_ptr->redraw |= (PR_MANA);
5254                                 }
5255
5256 #ifdef JP
5257                                 take_hit(DAMAGE_LOSELIFE, damroll(1, 12), "´í¸±¤ÊÈëÌ©", -1);
5258 #else
5259                                 take_hit(DAMAGE_LOSELIFE, damroll(1, 12), "perilous secrets", -1);
5260 #endif
5261
5262                                 /* Confusing. */
5263                                 if (one_in_(5)) (void)set_confused(p_ptr->confused +
5264                                         randint1(10));
5265
5266                                 /* Exercise a little care... */
5267                                 if (one_in_(20))
5268 #ifdef JP
5269                                         take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "´í¸±¤ÊÈëÌ©", -1);
5270 #else
5271                                         take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "perilous secrets", -1);
5272 #endif
5273                                 o_ptr->timeout = 0;
5274                                 break;
5275                         }
5276
5277                         case ART_BOROMIR:
5278                         {
5279                                 if (music_singing_any()) stop_singing();
5280                                 if (hex_spelling_any()) stop_hex_spell_all();
5281 #ifdef JP
5282                                 msg_print("¤¢¤Ê¤¿¤ÏÎ϶¯¤¤ÆÍÉ÷¤ò¿á¤­ÌĤ餷¤¿¡£¼þ°Ï¤ÎŨ¤¬¿Ì¤¨¾å¤Ã¤Æ¤¤¤ë!");
5283 #else
5284                                 msg_print("You wind a mighty blast; your enemies tremble!");
5285 #endif
5286                                 (void)turn_monsters((3 * p_ptr->lev / 2) + 10);
5287                                 o_ptr->timeout = randint0(40) + 40;
5288                                 break;
5289                         }
5290                         case ART_FARAMIR:
5291                         {
5292 #ifdef JP
5293                                 msg_print("¤¢¤Ê¤¿¤Ï³²Ãî¤ò°ìÁݤ·¤¿¡£");
5294 #else
5295                                 msg_print("You exterminate small life.");
5296 #endif
5297                                 (void)dispel_monsters(4);
5298                                 o_ptr->timeout = randint0(55) + 55;
5299                                 break;
5300                         }
5301
5302                         case ART_HIMRING:
5303                         {
5304 #ifdef JP
5305                                 msg_print("Æߤ¤²»¤¬ÊÕ¤ê¤òÊñ¤ß¤³¤ó¤À¡£");
5306 #else
5307                                 msg_print("A shrill wailing sound surrounds you.");
5308 #endif
5309                                 (void)set_protevil(randint1(25) + p_ptr->lev, FALSE);
5310                                 o_ptr->timeout = randint0(200) + 200;
5311                                 break;
5312                         }
5313
5314                         case ART_ICANUS:
5315                         {
5316
5317 #ifdef JP
5318                                 msg_print("¥í¡¼¥Ö¤¬½ã¿è¤ÊËâÎϤǿ̤¨¤¿¡£");
5319 #else
5320                                 msg_print("The robe pulsates with raw mana...");
5321 #endif
5322                                 if (!get_aim_dir(&dir)) return;
5323                                 fire_bolt(GF_MANA, dir, 120);
5324                                 o_ptr->timeout = randint0(120) + 120;
5325                                 break;
5326                         }
5327                         case ART_HURIN:
5328                         {
5329                                 (void)set_fast(randint1(50) + 50, FALSE);
5330                                 hp_player(10);
5331                                 set_afraid(0);
5332                                 set_hero(randint1(50) + 50, FALSE);
5333                                 o_ptr->timeout = randint0(200) + 100;
5334                                 break;
5335                         }
5336                         case ART_GIL_GALAD:
5337                         {
5338 #ifdef JP
5339                                 msg_print("¥·¡¼¥ë¥É¤¬âÁ¤·¤¤¸÷¤Çµ±¤¤¤¿¡¥¡¥¡¥");
5340 #else
5341                                 msg_print("Your shield gleams with blinding light...");
5342 #endif
5343                                 fire_ball(GF_LITE, 0, 300, 6);
5344                                 confuse_monsters(3 * p_ptr->lev / 2);
5345                                 o_ptr->timeout = 250;
5346                                 break;
5347                         }
5348                         case ART_YENDOR:
5349                         {
5350 #ifdef JP
5351                                 msg_print("¥«¡¼¥É¤¬Çò¤¯µ±¤¤¤¿¡¥¡¥¡¥");
5352 #else
5353                                 msg_print("Your card gleams with blinding light...");
5354 #endif
5355                                 if (!recharge(1000)) return;
5356                                 o_ptr->timeout = 200;
5357                                 break;
5358                         }
5359                         case ART_MURAMASA:
5360                         {
5361 #ifdef JP
5362                                 if (get_check("ËÜÅö¤Ë»È¤¤¤Þ¤¹¤«¡©"))
5363 #else
5364                                 if (get_check("Are you sure?!"))
5365 #endif
5366                                 {
5367 #ifdef JP
5368                                         msg_print("¼Àµ¤¬¿Ì¤¨¤¿¡¥¡¥¡¥");
5369 #else
5370                                         msg_print("The Muramasa pulsates...");
5371 #endif
5372                                         do_inc_stat(A_STR);
5373                                         if (one_in_(2))
5374                                         {
5375 #ifdef JP
5376                                                 msg_print("¼Àµ¤Ï²õ¤ì¤¿¡ª");
5377 #else
5378                                                 msg_print("The Muramasa is destroyed!");
5379 #endif
5380                                                 curse_weapon(TRUE, item);
5381                                         }
5382                                 }
5383                                 break;
5384                         }
5385                         case ART_FLY_STONE:
5386                         {
5387 #ifdef JP
5388                                 msg_print("ÀФ¬ÀÄÇò¤¯¸÷¤Ã¤¿¡¥¡¥¡¥");
5389 #else
5390                                 msg_print("Your stone glows pale...");
5391 #endif
5392
5393                                 if (!get_aim_dir(&dir)) return;
5394                                 fire_ball(GF_MANA, dir, 400, 4);
5395                                 o_ptr->timeout = randint0(250) + 250;
5396                                 break;
5397                         }
5398                         case ART_TAIKOBO:
5399                         {
5400                                 int x, y;
5401
5402                                 if (!get_rep_dir2(&dir)) return;
5403                                 y = py+ddy[dir];
5404                                 x = px+ddx[dir];
5405                                 tsuri_dir = dir;
5406                                 if (!cave_have_flag_bold(y, x, FF_WATER))
5407                                 {
5408 #ifdef JP
5409                                         msg_print("¤½¤³¤Ï¿åÊդǤϤʤ¤¡£");
5410 #else
5411                                         msg_print("There is no fishing place.");
5412 #endif
5413                                         return;
5414                                 }
5415                                 else if (cave[y][x].m_idx)
5416                                 {
5417                                         char m_name[80];
5418                                         monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5419 #ifdef JP
5420                                         msg_format("%s¤¬¼ÙËâ¤À¡ª", m_name);
5421 #else
5422                                         msg_format("%^s is stand in your way.", m_name);
5423 #endif
5424                                         energy_use = 0;
5425                                         return;
5426                                 }
5427                                 set_action(ACTION_FISH);
5428                                 p_ptr->redraw |= (PR_STATE);
5429                                 break;
5430                         }
5431                         case ART_JONES:
5432                         {
5433                                 if (!get_aim_dir(&dir)) return;
5434 #ifdef JP
5435                                 msg_print("¥à¥Á¤ò¿­¤Ð¤·¤¿¡£");
5436 #else
5437                                 msg_print("You stretched your whip.");
5438 #endif
5439
5440                                 fetch(dir, 500, TRUE);
5441                                 o_ptr->timeout = randint0(25) + 25;
5442                                 break;
5443                         }
5444                         case ART_ARRYU:
5445                         {
5446                                 u32b mode = PM_ALLOW_GROUP;
5447                                 bool pet = !one_in_(5);
5448                                 if (pet) mode |= PM_FORCE_PET;
5449                                 else mode |= PM_NO_PET;
5450
5451                                 if (summon_specific((pet ? -1 : 0), py, px, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, mode))
5452                                 {
5453
5454                                         if (pet)
5455 #ifdef JP
5456                                                 msg_print("¥Ï¥¦¥ó¥É¤¬¤¢¤Ê¤¿¤Î²¼ËͤȤ·¤Æ½Ð¸½¤·¤¿¡£");
5457 #else
5458                                         msg_print("A group of hounds appear as your servant.");
5459 #endif
5460
5461                                         else
5462 #ifdef JP
5463                                                 msg_print("¥Ï¥¦¥ó¥É¤Ï¤¢¤Ê¤¿¤Ë²ç¤ò¸þ¤±¤Æ¤¤¤ë¡ª");
5464 #else
5465                                                 msg_print("A group of hounds appear as your enemy!");
5466 #endif
5467
5468                                 }
5469
5470                                 o_ptr->timeout = 300 + randint1(150);
5471                                 break;
5472                         }
5473
5474                         case ART_GAEBOLG:
5475                         {
5476 #ifdef JP
5477                                 msg_print("¥¹¥Ô¥¢¤ÏâÁ¤·¤¯µ±¤¤¤¿...");
5478 #else
5479                                 msg_print("Your spear grows brightly...");
5480 #endif
5481
5482                                 if (!get_aim_dir(&dir)) return;
5483                                 fire_ball(GF_LITE, dir, 200, 3);
5484                                 o_ptr->timeout = randint0(200) + 200;
5485                                 break;
5486                         }
5487
5488                         case ART_INROU:
5489                         {
5490                                 int count = 0, i;
5491                                 monster_type *m_ptr;
5492 #ifndef JP
5493                                 cptr kakusan = "";
5494 #endif
5495
5496                                 if (summon_named_creature(0, py, px, MON_SUKE, PM_FORCE_PET))
5497                                 {
5498 #ifdef JP
5499                                         msg_print("¡Ø½õ¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
5500 #else
5501                                         msg_print("Suke-san apperars.");
5502                                         kakusan = "Suke-san";
5503 #endif
5504                                         count++;
5505                                 }
5506                                 if (summon_named_creature(0, py, px, MON_KAKU, PM_FORCE_PET))
5507                                 {
5508 #ifdef JP
5509                                         msg_print("¡Ø³Ê¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
5510 #else
5511                                         msg_print("Kaku-san appears.");
5512                                         kakusan = "Kaku-san";
5513 #endif
5514                                         count++;
5515                                 }
5516                                 if (!count)
5517                                 {
5518                                         for (i = m_max - 1; i > 0; i--)
5519                                         {
5520                                                 m_ptr = &m_list[i];
5521                                                 if (!m_ptr->r_idx) continue;
5522                                                 if (!((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) continue;
5523                                                 if (!los(m_ptr->fy, m_ptr->fx, py, px)) continue;
5524                                                 if (!projectable(m_ptr->fy, m_ptr->fx, py, px)) continue;
5525                                                 count++;
5526                                                 break;
5527                                         }
5528                                 }
5529
5530                                 if (count)
5531                                 {
5532 #ifdef JP
5533                                         msg_print("¡Ö¼Ô¤É¤â¡¢¤Ò¤«¤¨¤ª¤í¤¦¡ª¡ª¡ª¤³¤Î¤ªÊý¤ò¤É¤Ê¤¿¤È¤³¤³¤í¤¨¤ë¡£¡×");
5534 #else
5535                                         msg_format("%^s says 'WHO do you think this person is! Bow your head, down your knees!'", kakusan);
5536 #endif
5537
5538                                         sukekaku = TRUE;
5539                                         stun_monsters(120);
5540                                         confuse_monsters(120);
5541                                         turn_monsters(120);
5542                                         stasis_monsters(120);
5543                                         sukekaku = FALSE;
5544                                 }
5545                                 else
5546                                 {
5547 #ifdef JP
5548                                         msg_print("¤·¤«¤·¡¢²¿¤âµ¯¤­¤Ê¤«¤Ã¤¿¡£");
5549 #else
5550                                         msg_print("Nothing happen.");
5551 #endif
5552                                 }
5553                                 o_ptr->timeout = randint0(150) + 150;
5554                                 break;
5555                         }
5556
5557                         case ART_HYOUSIGI:
5558                         {
5559 #ifdef JP
5560                                 msg_print("Çï»ÒÌÚ¤òÂǤä¿¡£");
5561 #else
5562                                 msg_print("You beat Your wooden clappers.");
5563 #endif
5564                                 aggravate_monsters(0);
5565                                 break;
5566                         }
5567
5568                         case ART_MATOI:
5569                         case ART_AEGISFANG:
5570                         {
5571                                 (void)set_afraid(0);
5572                                 set_hero(randint1(25)+25, FALSE);
5573                                 hp_player(10);
5574                                 o_ptr->timeout = randint0(30) + 30;
5575                                 break;
5576                         }
5577
5578                         case ART_EARENDIL:
5579                         {
5580                                 (void)set_poisoned(0);
5581                                 (void)set_confused(0);
5582                                 (void)set_blind(0);
5583                                 (void)set_stun(0);
5584                                 (void)set_cut(0);
5585                                 (void)set_image(0);
5586
5587                                 o_ptr->timeout = 100;
5588                                 break;
5589                         }
5590
5591                         case ART_BOLISHOI:
5592                         {
5593                                 if (!get_aim_dir(&dir)) return;
5594                                 (void)charm_animal(dir, p_ptr->lev);
5595
5596                                 o_ptr->timeout = 200;
5597                                 break;
5598                         }
5599
5600                         case ART_ARUNRUTH:
5601                         {
5602 #ifdef JP
5603                                 msg_print("¥½¡¼¥É¤¬Ã¸¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
5604 #else
5605                                 msg_print("Your sword glows a pale blue...");
5606 #endif
5607                                 if (!get_aim_dir(&dir)) return;
5608                                 fire_bolt(GF_COLD, dir, damroll(12, 8));
5609                                 o_ptr->timeout = 50;
5610                                 break;
5611                         }
5612                         case ART_BLOOD:
5613                         {
5614 #ifdef JP
5615                                 msg_print("³ù¤¬ÌÀ¤ë¤¯µ±¤¤¤¿...");
5616 #else
5617                                 msg_print("Your scythe glows brightly!");
5618 #endif
5619                                 get_bloody_moon_flags(o_ptr);
5620                                 o_ptr->timeout = 3333;
5621                                 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
5622                                 p_ptr->update |= (PU_BONUS | PU_HP);
5623                                 break;
5624                         }
5625                         case ART_KESHO:
5626                         {
5627 #ifdef JP
5628                                 msg_print("Î϶¯¤¯»Í¸Ô¤òƧ¤ó¤À¡£");
5629 #else
5630                                 msg_print("You stamp. (as if you are in a ring.)");
5631 #endif
5632                                 (void)set_afraid(0);
5633                                 (void)set_hero(randint1(20) + 20, FALSE);
5634                                 dispel_evil(p_ptr->lev * 3);
5635                                 o_ptr->timeout = 100 + randint1(100);
5636                                 break;
5637                         }
5638                         case ART_MOOK:
5639                         {
5640 #ifdef JP
5641                                 msg_print("¥¯¥í¡¼¥¯¤¬Çò¤¯µ±¤¤¤¿...");
5642 #else
5643                                 msg_print("Your cloak grows white.");
5644 #endif
5645                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
5646                                 o_ptr->timeout = 40 + randint1(40);
5647                                 break;
5648                         }
5649                         case ART_HERMIT:
5650                         {
5651 #ifdef JP
5652                                 msg_print("¥à¥Á¤«¤é±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
5653 #else
5654                                 msg_print("The whip lets out a shrill wail...");
5655 #endif
5656
5657                                 k = 3 * p_ptr->lev;
5658                                 (void)set_protevil(randint1(25) + k, FALSE);
5659                                 o_ptr->timeout = randint0(225) + 225;
5660                                 break;
5661                         }
5662                         case ART_JIZO:
5663                         {
5664                                 u32b mode = PM_ALLOW_GROUP;
5665                                 bool pet = !one_in_(5);
5666                                 if (pet) mode |= PM_FORCE_PET;
5667
5668                                 if (summon_named_creature(0, py, px, MON_JIZOTAKO, mode))
5669                                 {
5670                                         if (pet)
5671 #ifdef JP
5672                                                 msg_print("Âý¤¬¤¢¤Ê¤¿¤Î²¼ËͤȤ·¤Æ½Ð¸½¤·¤¿¡£");
5673 #else
5674                                         msg_print("A group of octopuses appear as your servant.");
5675 #endif
5676
5677                                         else
5678 #ifdef JP
5679                                                 msg_print("Âý¤Ï¤¢¤Ê¤¿¤òâˤó¤Ç¤¤¤ë¡ª");
5680 #else
5681                                                 msg_print("A group of octopuses appear as your enemy!");
5682 #endif
5683
5684                                 }
5685
5686                                 o_ptr->timeout = 300 + randint1(150);
5687                                 break;
5688                         }
5689
5690                         case ART_FUNDIN:
5691                         {
5692 #ifdef JP
5693                                 msg_print("Å´µå¤ÏÊÕ¤ê¤òÁ±¤Î¥ª¡¼¥é¤ÇËþ¤¿¤·¤¿...");
5694 #else
5695                                 msg_print("The iron ball floods the area with goodness...");
5696 #endif
5697
5698                                 dispel_evil(p_ptr->lev * 5);
5699                                 o_ptr->timeout = randint0(100) + 100;
5700                                 break;
5701                         }
5702
5703                         case ART_AESCULAPIUS:
5704                         {
5705 #ifdef JP
5706                                 msg_print("Ï»¼ÜËÀ¤ÏÇ»Îп§¤Ëµ±¤¤¤Æ¤¤¤ë...");
5707 #else
5708                                 msg_print("The jo staff glows a deep green...");
5709 #endif
5710
5711                                 (void)do_res_stat(A_STR);
5712                                 (void)do_res_stat(A_INT);
5713                                 (void)do_res_stat(A_WIS);
5714                                 (void)do_res_stat(A_DEX);
5715                                 (void)do_res_stat(A_CON);
5716                                 (void)do_res_stat(A_CHR);
5717                                 (void)restore_level();
5718                                 o_ptr->timeout = 750;
5719                                 break;
5720                         }
5721
5722                         case ART_NIGHT:
5723                         {
5724 #ifdef JP
5725                                 msg_print("¥¢¥ß¥å¥ì¥Ã¥È¤¬¿¼¤¤°Ç¤Ëʤ¤ï¤ì¤¿...");
5726 #else
5727                                 msg_print("Your amulet is coverd in pitch-darkness...");
5728 #endif
5729                                 if (!get_aim_dir(&dir)) return;
5730                                 fire_ball(GF_DARK, dir, 250, 4);
5731                                 o_ptr->timeout = randint0(150) + 150;
5732                                 break;
5733                         }
5734                         case ART_HELL:
5735                         {
5736 #ifdef JP
5737                                 msg_print("¼óÎؤ¬¿¼¤¤°Ç¤Ëʤ¤ï¤ì¤¿...");
5738 #else
5739                                 msg_print("Your collar harness is coverd in pitch-darkness...");
5740 #endif
5741                                 if (!get_aim_dir(&dir)) return;
5742                                 fire_ball(GF_DARK, dir, 250, 4);
5743                                 o_ptr->timeout = randint0(150) + 150;
5744                                 break;
5745                         }
5746                         case ART_SACRED_KNIGHTS:
5747                         {
5748 #ifdef JP
5749                                 msg_print("¼ó¾þ¤ê¤¬¿¿¼Â¤ò¾È¤é¤·½Ð¤¹...");
5750 #else
5751                                 msg_print("Your amulet exhibits the truth...");
5752 #endif
5753                                 if (remove_all_curse())
5754                                 {
5755 #ifdef JP
5756                                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
5757 #else
5758                                         msg_print("You feel as if someone is watching over you.");
5759 #endif
5760                                 }
5761                                 (void)probing();
5762                                 break;
5763                         }
5764                         case ART_CHARMED:
5765                         {
5766 #ifdef JP
5767                                 msg_print("¥Ú¥ó¥À¥ó¥È¤¬ÀÄÇò¤¯¸÷¤Ã¤¿¡¥¡¥¡¥");
5768 #else
5769                                 msg_print("Your pendant glows pale...");
5770 #endif
5771                                 if (p_ptr->pclass == CLASS_MAGIC_EATER)
5772                                 {
5773                                         int i;
5774                                         for (i = 0; i < EATER_EXT*2; i++)
5775                                         {
5776                                                 p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i]*EATER_CHARGE/3;
5777                                                 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;
5778                                         }
5779                                         for (; i < EATER_EXT*3; i++)
5780                                         {
5781                                                 int k_idx = lookup_kind(TV_ROD, i-EATER_EXT*2);
5782                                                 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;
5783                                                 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
5784                                         }
5785 #ifdef JP
5786                                         msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
5787 #else
5788                                         msg_print("You feel your head clear.");
5789 #endif
5790                                         p_ptr->window |= (PW_PLAYER);
5791                                 }
5792                                 else if (p_ptr->csp < p_ptr->msp)
5793                                 {
5794                                         p_ptr->csp = p_ptr->msp;
5795                                         p_ptr->csp_frac = 0;
5796 #ifdef JP
5797                                         msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
5798 #else
5799                                         msg_print("You feel your head clear.");
5800 #endif
5801
5802                                         p_ptr->redraw |= (PR_MANA);
5803                                         p_ptr->window |= (PW_PLAYER);
5804                                         p_ptr->window |= (PW_SPELL);
5805                                 }
5806                                 o_ptr->timeout = 777;
5807                                 break;
5808                         }
5809                 }
5810
5811                 /* Window stuff */
5812                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5813
5814                 /* Done */
5815                 return;
5816         }
5817
5818         if (object_is_smith(o_ptr))
5819         {
5820                 switch (o_ptr->xtra3-1)
5821                 {
5822                 case ESSENCE_TMP_RES_ACID:
5823                         (void)set_oppose_acid(randint1(20) + 20, FALSE);
5824                         o_ptr->timeout = randint0(50) + 50;
5825                         return;
5826
5827                 case ESSENCE_TMP_RES_ELEC:
5828                         (void)set_oppose_elec(randint1(20) + 20, FALSE);
5829                         o_ptr->timeout = randint0(50) + 50;
5830                         return;
5831
5832                 case ESSENCE_TMP_RES_FIRE:
5833                         (void)set_oppose_fire(randint1(20) + 20, FALSE);
5834                         o_ptr->timeout = randint0(50) + 50;
5835                         return;
5836
5837                 case ESSENCE_TMP_RES_COLD:
5838                         (void)set_oppose_cold(randint1(20) + 20, FALSE);
5839                         o_ptr->timeout = randint0(50) + 50;
5840                         return;
5841
5842                 case TR_IMPACT:
5843                         earthquake(py, px, 5);
5844                         o_ptr->timeout = 100 + randint1(100);
5845                         
5846                         /* Window stuff */
5847                         p_ptr->window |= (PW_INVEN | PW_EQUIP);
5848
5849                         /* Done */
5850                         return;
5851                 }
5852         }
5853
5854
5855         if (o_ptr->name2 == EGO_TRUMP)
5856         {
5857                 teleport_player(100, 0L);
5858                 o_ptr->timeout = 50 + randint1(50);
5859
5860                 /* Window stuff */
5861                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5862
5863                 /* Done */
5864                 return;
5865         }
5866
5867
5868         if (o_ptr->name2 == EGO_LITE_ILLUMINATION)
5869         {
5870                 if (!o_ptr->xtra4 && ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN)))
5871                 {
5872 #ifdef JP
5873                         msg_print("dzÎÁ¤¬¤Ê¤¤¡£");
5874 #else
5875                         msg_print("It has no fuel.");
5876 #endif
5877                         energy_use = 0;
5878                         return;
5879                 }
5880                 lite_area(damroll(2, 15), 3);
5881                 o_ptr->timeout = randint0(10) + 10;
5882
5883                 /* Window stuff */
5884                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5885
5886                 return;
5887         }
5888
5889
5890         if (o_ptr->name2 == EGO_EARTHQUAKES)
5891         {
5892                 earthquake(py, px, 5);
5893                 o_ptr->timeout = 100 + randint1(100);
5894
5895                 /* Window stuff */
5896                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5897
5898                 /* Done */
5899                 return;
5900         }
5901
5902
5903         if (o_ptr->name2 == EGO_JUMP)
5904         {
5905                 teleport_player(10, 0L);
5906                 o_ptr->timeout = 10 + randint1(10);
5907
5908                 /* Window stuff */
5909                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5910
5911                 /* Done */
5912                 return;
5913         }
5914
5915
5916         /* Hack -- Dragon Scale Mail can be activated as well */
5917         if (o_ptr->tval == TV_DRAG_ARMOR)
5918         {
5919                 /* Get a direction for breathing (or abort) */
5920                 if (!get_aim_dir(&dir)) return;
5921
5922                 if (music_singing_any()) stop_singing();
5923                 if (hex_spelling_any()) stop_hex_spell_all();
5924
5925                 /* Branch on the sub-type */
5926                 switch (o_ptr->sval)
5927                 {
5928                         case SV_DRAGON_BLUE:
5929                         {
5930 #ifdef JP
5931                                 msg_print("¤¢¤Ê¤¿¤Ï°ðºÊ¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5932 #else
5933                                 msg_print("You breathe lightning.");
5934 #endif
5935
5936                                 fire_ball(GF_ELEC, dir, 100, -2);
5937                                 o_ptr->timeout = randint0(150) + 150;
5938                                 break;
5939                         }
5940
5941                         case SV_DRAGON_WHITE:
5942                         {
5943 #ifdef JP
5944                                 msg_print("¤¢¤Ê¤¿¤ÏÎ䵤¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5945 #else
5946                                 msg_print("You breathe frost.");
5947 #endif
5948
5949                                 fire_ball(GF_COLD, dir, 110, -2);
5950                                 o_ptr->timeout = randint0(150) + 150;
5951                                 break;
5952                         }
5953
5954                         case SV_DRAGON_BLACK:
5955                         {
5956 #ifdef JP
5957                                 msg_print("¤¢¤Ê¤¿¤Ï»À¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5958 #else
5959                                 msg_print("You breathe acid.");
5960 #endif
5961
5962                                 fire_ball(GF_ACID, dir, 130, -2);
5963                                 o_ptr->timeout = randint0(150) + 150;
5964                                 break;
5965                         }
5966
5967                         case SV_DRAGON_GREEN:
5968                         {
5969 #ifdef JP
5970                                 msg_print("¤¢¤Ê¤¿¤ÏÆÇ¥¬¥¹¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5971 #else
5972                                 msg_print("You breathe poison gas.");
5973 #endif
5974
5975                                 fire_ball(GF_POIS, dir, 150, -2);
5976                                 o_ptr->timeout = randint0(180) + 180;
5977                                 break;
5978                         }
5979
5980                         case SV_DRAGON_RED:
5981                         {
5982 #ifdef JP
5983                                 msg_print("¤¢¤Ê¤¿¤Ï²Ð±ê¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5984 #else
5985                                 msg_print("You breathe fire.");
5986 #endif
5987
5988                                 fire_ball(GF_FIRE, dir, 200, -2);
5989                                 o_ptr->timeout = randint0(200) + 200;
5990                                 break;
5991                         }
5992
5993                         case SV_DRAGON_MULTIHUED:
5994                         {
5995                                 chance = randint0(5);
5996 #ifdef JP
5997                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
5998                                            ((chance == 1) ? "°ðºÊ" :
5999                                             ((chance == 2) ? "Î䵤" :
6000                                              ((chance == 3) ? "»À" :
6001                                               ((chance == 4) ? "ÆÇ¥¬¥¹" : "²Ð±ê")))));
6002 #else
6003                                 msg_format("You breathe %s.",
6004                                            ((chance == 1) ? "lightning" :
6005                                             ((chance == 2) ? "frost" :
6006                                              ((chance == 3) ? "acid" :
6007                                               ((chance == 4) ? "poison gas" : "fire")))));
6008 #endif
6009
6010                                 fire_ball(((chance == 1) ? GF_ELEC :
6011                                            ((chance == 2) ? GF_COLD :
6012                                             ((chance == 3) ? GF_ACID :
6013                                              ((chance == 4) ? GF_POIS : GF_FIRE)))),
6014                                           dir, 250, -2);
6015                                 o_ptr->timeout = randint0(200) + 200;
6016                                 break;
6017                         }
6018
6019                         case SV_DRAGON_BRONZE:
6020                         {
6021 #ifdef JP
6022                                 msg_print("¤¢¤Ê¤¿¤Ïº®Íð¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
6023 #else
6024                                 msg_print("You breathe confusion.");
6025 #endif
6026
6027                                 fire_ball(GF_CONFUSION, dir, 120, -2);
6028                                 o_ptr->timeout = randint0(180) + 180;
6029                                 break;
6030                         }
6031
6032                         case SV_DRAGON_GOLD:
6033                         {
6034 #ifdef JP
6035                                 msg_print("¤¢¤Ê¤¿¤Ï¹ì²»¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
6036 #else
6037                                 msg_print("You breathe sound.");
6038 #endif
6039
6040                                 fire_ball(GF_SOUND, dir, 130, -2);
6041                                 o_ptr->timeout = randint0(180) + 180;
6042                                 break;
6043                         }
6044
6045                         case SV_DRAGON_CHAOS:
6046                         {
6047                                 chance = randint0(2);
6048 #ifdef JP
6049                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
6050                                            ((chance == 1 ? "¥«¥ª¥¹" : "Îô²½")));
6051 #else
6052                                 msg_format("You breathe %s.",
6053                                            ((chance == 1 ? "chaos" : "disenchantment")));
6054 #endif
6055
6056                                 fire_ball((chance == 1 ? GF_CHAOS : GF_DISENCHANT),
6057                                           dir, 220, -2);
6058                                 o_ptr->timeout = randint0(200) + 200;
6059                                 break;
6060                         }
6061
6062                         case SV_DRAGON_LAW:
6063                         {
6064                                 chance = randint0(2);
6065 #ifdef JP
6066                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
6067                                            ((chance == 1 ? "¹ì²»" : "ÇËÊÒ")));
6068 #else
6069                                 msg_format("You breathe %s.",
6070                                            ((chance == 1 ? "sound" : "shards")));
6071 #endif
6072
6073                                 fire_ball((chance == 1 ? GF_SOUND : GF_SHARDS),
6074                                           dir, 230, -2);
6075                                 o_ptr->timeout = randint0(200) + 200;
6076                                 break;
6077                         }
6078
6079                         case SV_DRAGON_BALANCE:
6080                         {
6081                                 chance = randint0(4);
6082 #ifdef JP
6083                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿",
6084                                            ((chance == 1) ? "¥«¥ª¥¹" :
6085                                             ((chance == 2) ? "Îô²½" :
6086                                              ((chance == 3) ? "¹ì²»" : "ÇËÊÒ"))));
6087 #else
6088                                 msg_format("You breathe %s.",
6089                                            ((chance == 1) ? "chaos" :
6090                                             ((chance == 2) ? "disenchantment" :
6091                                              ((chance == 3) ? "sound" : "shards"))));
6092 #endif
6093
6094                                 fire_ball(((chance == 1) ? GF_CHAOS :
6095                                            ((chance == 2) ? GF_DISENCHANT :
6096                                             ((chance == 3) ? GF_SOUND : GF_SHARDS))),
6097                                           dir, 250, -2);
6098                                 o_ptr->timeout = randint0(200) + 200;
6099                                 break;
6100                         }
6101
6102                         case SV_DRAGON_SHINING:
6103                         {
6104                                 chance = randint0(2);
6105 #ifdef JP
6106                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
6107                                            ((chance == 0 ? "Á®¸÷" : "°Å¹õ")));
6108 #else
6109                                 msg_format("You breathe %s.",
6110                                            ((chance == 0 ? "light" : "darkness")));
6111 #endif
6112
6113                                 fire_ball((chance == 0 ? GF_LITE : GF_DARK), dir, 200, -2);
6114                                 o_ptr->timeout = randint0(200) + 200;
6115                                 break;
6116                         }
6117
6118                         case SV_DRAGON_POWER:
6119                         {
6120 #ifdef JP
6121 msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
6122 #else
6123                                 msg_print("You breathe the elements.");
6124 #endif
6125
6126                                 fire_ball(GF_MISSILE, dir, 300, -3);
6127                                 o_ptr->timeout = randint0(200) + 200;
6128                                 break;
6129                         }
6130                 }
6131
6132                 /* Window stuff */
6133                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
6134
6135                 /* Success */
6136                 return;
6137         }
6138
6139         else if (o_ptr->tval == TV_RING)
6140         {
6141                 if (object_is_ego(o_ptr))
6142                 {
6143                         bool success = TRUE;
6144
6145                         switch (o_ptr->name2)
6146                         {
6147                         case EGO_RING_HERO:
6148                                 (void)set_afraid(0);
6149                                 (void)set_hero(randint1(25) + 25, FALSE);
6150                                 (void)hp_player(10);
6151                                 o_ptr->timeout = randint1(100)+100;
6152                                 break;
6153                         case EGO_RING_MAGIC_MIS:
6154                                 if (!get_aim_dir(&dir)) return;
6155                                 fire_bolt(GF_MISSILE, dir, damroll(2, 6));
6156                                 o_ptr->timeout = 2;
6157                                 break;
6158                         case EGO_RING_FIRE_BOLT:
6159                                 if (!get_aim_dir(&dir)) return;
6160                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
6161                                 o_ptr->timeout = randint0(8) + 8;
6162                                 break;
6163                         case EGO_RING_COLD_BOLT:
6164                                 if (!get_aim_dir(&dir)) return;
6165                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
6166                                 o_ptr->timeout = randint0(7) + 7;
6167                                 break;
6168                         case EGO_RING_ELEC_BOLT:
6169                                 if (!get_aim_dir(&dir)) return;
6170                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
6171                                 o_ptr->timeout = randint0(5) + 5;
6172                                 break;
6173                         case EGO_RING_ACID_BOLT:
6174                                 if (!get_aim_dir(&dir)) return;
6175                                 fire_bolt(GF_ACID, dir, damroll(5, 8));
6176                                 o_ptr->timeout = randint0(6) + 6;
6177                                 break;
6178                         case EGO_RING_MANA_BOLT:
6179                                 if (!get_aim_dir(&dir)) return;
6180                                 fire_bolt(GF_MANA, dir, 120);
6181                                 o_ptr->timeout = randint0(120)+120;
6182                                 break;
6183                         case EGO_RING_FIRE_BALL:
6184                                 if (!get_aim_dir(&dir)) return;
6185                                 fire_ball(GF_FIRE, dir, 100, 2);
6186                                 o_ptr->timeout = randint0(80) + 80;
6187                                 break;
6188                         case EGO_RING_COLD_BALL:
6189                                 if (!get_aim_dir(&dir)) return;
6190                                 fire_ball(GF_COLD, dir, 100, 2);
6191                                 o_ptr->timeout = randint0(80) + 80;
6192                                 break;
6193                         case EGO_RING_ELEC_BALL:
6194                                 if (!get_aim_dir(&dir)) return;
6195                                 fire_ball(GF_ELEC, dir, 100, 2);
6196                                 o_ptr->timeout = randint0(80) + 80;
6197                                 break;
6198                         case EGO_RING_ACID_BALL:
6199                                 if (!get_aim_dir(&dir)) return;
6200                                 fire_ball(GF_ACID, dir, 100, 2);
6201                                 o_ptr->timeout = randint0(80) + 80;
6202                                 break;
6203                         case EGO_RING_MANA_BALL:
6204                                 if (!get_aim_dir(&dir)) return;
6205                                 fire_ball(GF_MANA, dir, 250, 2);
6206                                 o_ptr->timeout = 300;
6207                                 break;
6208                         case EGO_RING_DRAGON_F:
6209                                 if (!get_aim_dir(&dir)) return;
6210                                 fire_ball(GF_FIRE, dir, 200, -2);
6211                                 if (o_ptr->sval == SV_RING_FLAMES)
6212                                 {
6213                                         (void)set_oppose_fire(randint1(20) + 20, FALSE);
6214                                         o_ptr->timeout = 200;
6215                                 }
6216                                 else o_ptr->timeout = 250;
6217                                 break;
6218                         case EGO_RING_DRAGON_C:
6219                                 if (!get_aim_dir(&dir)) return;
6220                                 fire_ball(GF_COLD, dir, 200, -2);
6221                                 if (o_ptr->sval == SV_RING_ICE)
6222                                 {
6223                                         (void)set_oppose_cold(randint1(20) + 20, FALSE);
6224                                         o_ptr->timeout = 200;
6225                                 }
6226                                 else o_ptr->timeout = 250;
6227                                 break;
6228                         case EGO_RING_M_DETECT:
6229                                 (void)detect_monsters_invis(255);
6230                                 (void)detect_monsters_normal(255);
6231                                 o_ptr->timeout = 150;
6232                                 break;
6233                         case EGO_RING_D_SPEED:
6234                                 (void)set_fast(randint1(30) + 15, FALSE);
6235                                 o_ptr->timeout = 100;
6236                                 break;
6237                         case EGO_RING_BERSERKER:
6238                                 (void)set_afraid(0);
6239                                 (void)set_shero(randint1(25) + 25, FALSE);
6240                                 o_ptr->timeout = randint0(75)+75;
6241                                 break;
6242                         case EGO_RING_TELE_AWAY:
6243                                 if (!get_aim_dir(&dir)) return;
6244                                 teleport_monster(dir);
6245                                 o_ptr->timeout = 150;
6246                                 break;
6247                         case EGO_RING_TRUE:
6248                         {
6249                                 int v = randint1(25)+25;
6250                                 (void)set_afraid(0);
6251                                 (void)set_hero(v, FALSE);
6252                                 (void)hp_player(10);
6253                                 (void)set_blessed(v, FALSE);
6254                                 (void)set_oppose_acid(v, FALSE);
6255                                 (void)set_oppose_elec(v, FALSE);
6256                                 (void)set_oppose_fire(v, FALSE);
6257                                 (void)set_oppose_cold(v, FALSE);
6258                                 (void)set_oppose_pois(v, FALSE);
6259                                 (void)set_ultimate_res(v, FALSE);
6260                                 o_ptr->timeout = 777;
6261                                 break;
6262                         }
6263                         default:
6264                                 success = FALSE;
6265                                 break;
6266                         }
6267                         if (success) return;
6268                 }
6269
6270                 /* Get a direction for breathing (or abort) */
6271                 if (!get_aim_dir(&dir)) return;
6272
6273                 switch (o_ptr->sval)
6274                 {
6275                         case SV_RING_ACID:
6276                         {
6277                                 fire_ball(GF_ACID, dir, 100, 2);
6278                                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
6279                                 o_ptr->timeout = randint0(50) + 50;
6280                                 break;
6281                         }
6282
6283                         case SV_RING_ICE:
6284                         {
6285                                 fire_ball(GF_COLD, dir, 100, 2);
6286                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
6287                                 o_ptr->timeout = randint0(50) + 50;
6288                                 break;
6289                         }
6290
6291                         case SV_RING_FLAMES:
6292                         {
6293                                 fire_ball(GF_FIRE, dir, 100, 2);
6294                                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
6295                                 o_ptr->timeout = randint0(50) + 50;
6296                                 break;
6297                         }
6298
6299                         case SV_RING_ELEC:
6300                         {
6301                                 fire_ball(GF_ELEC, dir, 100, 2);
6302                                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
6303                                 o_ptr->timeout = randint0(50) + 50;
6304                                 break;
6305                         }
6306                 }
6307
6308                 /* Window stuff */
6309                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
6310
6311                 /* Success */
6312                 return;
6313         }
6314
6315         else if (o_ptr->tval == TV_AMULET)
6316         {
6317                 if (object_is_ego(o_ptr))
6318                 {
6319                         switch (o_ptr->name2)
6320                         {
6321                         case EGO_AMU_IDENT:
6322                                 if (!ident_spell(FALSE)) return;
6323                                 o_ptr->timeout = 10;
6324                                 break;
6325                         case EGO_AMU_CHARM:
6326                                 if (!get_aim_dir(&dir)) return;
6327                                 charm_monster(dir, MAX(20, p_ptr->lev));
6328                                 o_ptr->timeout = 200;
6329                                 break;
6330                         case EGO_AMU_JUMP:
6331                                 teleport_player(10, 0L);
6332                                 o_ptr->timeout = randint0(10) + 10;
6333                                 break;
6334                         case EGO_AMU_TELEPORT:
6335                                 teleport_player(100, 0L);
6336                                 o_ptr->timeout = randint0(50) + 50;
6337                                 break;
6338                         case EGO_AMU_D_DOOR:
6339                                 (void)dimension_door();
6340                                 o_ptr->timeout = 200;
6341                                 break;
6342                         case EGO_AMU_RES_FIRE_:
6343                                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
6344                                 o_ptr->timeout = randint0(50) + 50;
6345                                 break;
6346                         case EGO_AMU_RES_COLD_:
6347                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
6348                                 o_ptr->timeout = randint0(50) + 50;
6349                                 break;
6350                         case EGO_AMU_RES_ELEC_:
6351                                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
6352                                 o_ptr->timeout = randint0(50) + 50;
6353                                 break;
6354                         case EGO_AMU_RES_ACID_:
6355                                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
6356                                 o_ptr->timeout = randint0(50) + 50;
6357                                 break;
6358                         case EGO_AMU_DETECTION:
6359                                 detect_all(DETECT_RAD_DEFAULT);
6360                                 o_ptr->timeout = randint0(55)+55;
6361                                 break;
6362                         }
6363                 }
6364                 return;
6365         }
6366
6367         else if (o_ptr->tval == TV_WHISTLE)
6368         {
6369                 if (music_singing_any()) stop_singing();
6370                 if (hex_spelling_any()) stop_hex_spell_all();
6371
6372 #if 0
6373                 if (object_is_cursed(o_ptr))
6374                 {
6375 #ifdef JP
6376                         msg_print("¥«¥ó¹â¤¤²»¤¬¶Á¤­ÅϤä¿¡£");
6377 #else
6378                         msg_print("You produce a shrill whistling sound.");
6379 #endif
6380                         aggravate_monsters(0);
6381                 }
6382                 else
6383 #endif
6384                 {
6385                         int pet_ctr, i;
6386                         u16b *who;
6387                         int max_pet = 0;
6388                         u16b dummy_why;
6389
6390                         /* Allocate the "who" array */
6391                         C_MAKE(who, max_m_idx, u16b);
6392
6393                         /* Process the monsters (backwards) */
6394                         for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
6395                         {
6396                                 if (is_pet(&m_list[pet_ctr]) && (p_ptr->riding != pet_ctr))
6397                                   who[max_pet++] = pet_ctr;
6398                         }
6399
6400                         /* Select the sort method */
6401                         ang_sort_comp = ang_sort_comp_pet;
6402                         ang_sort_swap = ang_sort_swap_hook;
6403
6404                         ang_sort(who, &dummy_why, max_pet);
6405
6406                         /* Process the monsters (backwards) */
6407                         for (i = 0; i < max_pet; i++)
6408                         {
6409                                 pet_ctr = who[i];
6410                                 teleport_monster_to(pet_ctr, py, px, 100, TELEPORT_PASSIVE);
6411                         }
6412
6413                         /* Free the "who" array */
6414                         C_KILL(who, max_m_idx, u16b);
6415                 }
6416                 o_ptr->timeout = 100+randint1(100);
6417                 return;
6418         }
6419         else if (o_ptr->tval == TV_CAPTURE)
6420         {
6421                 if(!o_ptr->pval)
6422                 {
6423                         bool old_target_pet = target_pet;
6424                         target_pet = TRUE;
6425                         if (!get_aim_dir(&dir))
6426                         {
6427                                 target_pet = old_target_pet;
6428                                 return;
6429                         }
6430                         target_pet = old_target_pet;
6431
6432                         if(fire_ball(GF_CAPTURE, dir, 0, 0))
6433                         {
6434                                 o_ptr->pval = cap_mon;
6435                                 o_ptr->xtra3 = cap_mspeed;
6436                                 o_ptr->xtra4 = cap_hp;
6437                                 o_ptr->xtra5 = cap_maxhp;
6438                                 if (cap_nickname)
6439                                 {
6440                                         cptr t;
6441                                         char *s;
6442                                         char buf[80] = "";
6443
6444                                         if (o_ptr->inscription)
6445                                                 strcpy(buf, quark_str(o_ptr->inscription));
6446                                         s = buf;
6447                                         for (s = buf;*s && (*s != '#'); s++)
6448                                         {
6449 #ifdef JP
6450                                                 if (iskanji(*s)) s++;
6451 #endif
6452                                         }
6453                                         *s = '#';
6454                                         s++;
6455 #ifdef JP
6456  /*nothing*/
6457 #else
6458                                         *s++ = '\'';
6459 #endif
6460                                         t = quark_str(cap_nickname);
6461                                         while (*t)
6462                                         {
6463                                                 *s = *t;
6464                                                 s++;
6465                                                 t++;
6466                                         }
6467 #ifdef JP
6468  /*nothing*/
6469 #else
6470                                         *s++ = '\'';
6471 #endif
6472                                         *s = '\0';
6473                                         o_ptr->inscription = quark_add(buf);
6474                                 }
6475                         }
6476                 }
6477                 else
6478                 {
6479                         bool success = FALSE;
6480                         if (!get_rep_dir2(&dir)) return;
6481                         if (monster_can_enter(py + ddy[dir], px + ddx[dir], &r_info[o_ptr->pval], 0))
6482                         {
6483                                 if (place_monster_aux(0, py + ddy[dir], px + ddx[dir], o_ptr->pval, (PM_FORCE_PET | PM_NO_KAGE)))
6484                                 {
6485                                         if (o_ptr->xtra3) m_list[hack_m_idx_ii].mspeed = o_ptr->xtra3;
6486                                         if (o_ptr->xtra5) m_list[hack_m_idx_ii].max_maxhp = o_ptr->xtra5;
6487                                         if (o_ptr->xtra4) m_list[hack_m_idx_ii].hp = o_ptr->xtra4;
6488                                         m_list[hack_m_idx_ii].maxhp = m_list[hack_m_idx_ii].max_maxhp;
6489                                         if (o_ptr->inscription)
6490                                         {
6491                                                 char buf[80];
6492                                                 cptr t;
6493 #ifndef JP
6494                                                 bool quote = FALSE;
6495 #endif
6496
6497                                                 t = quark_str(o_ptr->inscription);
6498                                                 for (t = quark_str(o_ptr->inscription);*t && (*t != '#'); t++)
6499                                                 {
6500 #ifdef JP
6501                                                         if (iskanji(*t)) t++;
6502 #endif
6503                                                 }
6504                                                 if (*t)
6505                                                 {
6506                                                         char *s = buf;
6507                                                         t++;
6508 #ifdef JP
6509                                                         /* nothing */
6510 #else
6511                                                         if (*t =='\'')
6512                                                         {
6513                                                                 t++;
6514                                                                 quote = TRUE;
6515                                                         }
6516 #endif
6517                                                         while(*t)
6518                                                         {
6519                                                                 *s = *t;
6520                                                                 t++;
6521                                                                 s++;
6522                                                         }
6523 #ifdef JP
6524                                                         /* nothing */
6525 #else
6526                                                         if (quote && *(s-1) =='\'')
6527                                                                 s--;
6528 #endif
6529                                                         *s = '\0';
6530                                                         m_list[hack_m_idx_ii].nickname = quark_add(buf);
6531                                                         t = quark_str(o_ptr->inscription);
6532                                                         s = buf;
6533                                                         while(*t && (*t != '#'))
6534                                                         {
6535                                                                 *s = *t;
6536                                                                 t++;
6537                                                                 s++;
6538                                                         }
6539                                                         *s = '\0';
6540                                                         o_ptr->inscription = quark_add(buf);
6541                                                 }
6542                                         }
6543                                         o_ptr->pval = 0;
6544                                         o_ptr->xtra3 = 0;
6545                                         o_ptr->xtra4 = 0;
6546                                         o_ptr->xtra5 = 0;
6547                                         success = TRUE;
6548                                 }
6549                         }
6550                         if (!success)
6551 #ifdef JP
6552                                 msg_print("¤ª¤Ã¤È¡¢²òÊü¤Ë¼ºÇÔ¤·¤¿¡£");
6553 #else
6554                                 msg_print("Oops.  You failed to release your pet.");
6555 #endif
6556                 }
6557                 return;
6558         }
6559
6560         /* Mistake */
6561 #ifdef JP
6562         msg_print("¤ª¤Ã¤È¡¢¤³¤Î¥¢¥¤¥Æ¥à¤Ï»ÏÆ°¤Ç¤­¤Ê¤¤¡£");
6563 #else
6564         msg_print("Oops.  That object cannot be activated.");
6565 #endif
6566
6567 }
6568
6569
6570 void do_cmd_activate(void)
6571 {
6572         int     item;
6573         cptr    q, s;
6574
6575
6576         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
6577         {
6578                 set_action(ACTION_NONE);
6579         }
6580
6581         item_tester_no_ryoute = TRUE;
6582         /* Prepare the hook */
6583         item_tester_hook = item_tester_hook_activate;
6584
6585         /* Get an item */
6586 #ifdef JP
6587         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò»ÏÆ°¤µ¤»¤Þ¤¹¤«? ";
6588         s = "»ÏÆ°¤Ç¤­¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Ê¤¤¡£";
6589 #else
6590         q = "Activate which item? ";
6591         s = "You have nothing to activate.";
6592 #endif
6593
6594         if (!get_item(&item, q, s, (USE_EQUIP))) return;
6595
6596         /* Activate the item */
6597         do_cmd_activate_aux(item);
6598 }
6599
6600
6601 /*
6602  * Hook to determine if an object is useable
6603  */
6604 static bool item_tester_hook_use(object_type *o_ptr)
6605 {
6606         u32b flgs[TR_FLAG_SIZE];
6607
6608         /* Ammo */
6609         if (o_ptr->tval == p_ptr->tval_ammo)
6610                 return (TRUE);
6611
6612         /* Useable object */
6613         switch (o_ptr->tval)
6614         {
6615                 case TV_SPIKE:
6616                 case TV_STAFF:
6617                 case TV_WAND:
6618                 case TV_ROD:
6619                 case TV_SCROLL:
6620                 case TV_POTION:
6621                 case TV_FOOD:
6622                 {
6623                         return (TRUE);
6624                 }
6625
6626                 default:
6627                 {
6628                         int i;
6629
6630                         /* Not known */
6631                         if (!object_is_known(o_ptr)) return (FALSE);
6632
6633                         /* HACK - only items from the equipment can be activated */
6634                         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6635                         {
6636                                 if (&inventory[i] == o_ptr)
6637                                 {
6638                                         /* Extract the flags */
6639                                         object_flags(o_ptr, flgs);
6640
6641                                         /* Check activation flag */
6642                                         if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
6643                                 }
6644                         }
6645                 }
6646         }
6647
6648         /* Assume not */
6649         return (FALSE);
6650 }
6651
6652
6653 /*
6654  * Use an item
6655  * XXX - Add actions for other item types
6656  */
6657 void do_cmd_use(void)
6658 {
6659         int         item;
6660         object_type *o_ptr;
6661         cptr        q, s;
6662
6663         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
6664         {
6665                 set_action(ACTION_NONE);
6666         }
6667
6668         item_tester_no_ryoute = TRUE;
6669         /* Prepare the hook */
6670         item_tester_hook = item_tester_hook_use;
6671
6672         /* Get an item */
6673 #ifdef JP
6674 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
6675 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
6676 #else
6677         q = "Use which item? ";
6678         s = "You have nothing to use.";
6679 #endif
6680
6681         if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
6682
6683         /* Get the item (in the pack) */
6684         if (item >= 0)
6685         {
6686                 o_ptr = &inventory[item];
6687         }
6688         /* Get the item (on the floor) */
6689         else
6690         {
6691                 o_ptr = &o_list[0 - item];
6692         }
6693
6694         switch (o_ptr->tval)
6695         {
6696                 /* Spike a door */
6697                 case TV_SPIKE:
6698                 {
6699                         do_cmd_spike();
6700                         break;
6701                 }
6702
6703                 /* Eat some food */
6704                 case TV_FOOD:
6705                 {
6706                         do_cmd_eat_food_aux(item);
6707                         break;
6708                 }
6709
6710                 /* Aim a wand */
6711                 case TV_WAND:
6712                 {
6713                         do_cmd_aim_wand_aux(item);
6714                         break;
6715                 }
6716
6717                 /* Use a staff */
6718                 case TV_STAFF:
6719                 {
6720                         do_cmd_use_staff_aux(item);
6721                         break;
6722                 }
6723
6724                 /* Zap a rod */
6725                 case TV_ROD:
6726                 {
6727                         do_cmd_zap_rod_aux(item);
6728                         break;
6729                 }
6730
6731                 /* Quaff a potion */
6732                 case TV_POTION:
6733                 {
6734                         do_cmd_quaff_potion_aux(item);
6735                         break;
6736                 }
6737
6738                 /* Read a scroll */
6739                 case TV_SCROLL:
6740                 {
6741                         /* Check some conditions */
6742                         if (p_ptr->blind)
6743                         {
6744 #ifdef JP
6745 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡£");
6746 #else
6747                                 msg_print("You can't see anything.");
6748 #endif
6749
6750                                 return;
6751                         }
6752                         if (no_lite())
6753                         {
6754 #ifdef JP
6755 msg_print("ÌÀ¤«¤ê¤¬¤Ê¤¤¤Î¤Ç¡¢°Å¤¯¤ÆÆɤá¤Ê¤¤¡£");
6756 #else
6757                                 msg_print("You have no light to read by.");
6758 #endif
6759
6760                                 return;
6761                         }
6762                         if (p_ptr->confused)
6763                         {
6764 #ifdef JP
6765 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡ª");
6766 #else
6767                                 msg_print("You are too confused!");
6768 #endif
6769
6770                                 return;
6771                         }
6772
6773                   do_cmd_read_scroll_aux(item, TRUE);
6774                   break;
6775                 }
6776
6777                 /* Fire ammo */
6778                 case TV_SHOT:
6779                 case TV_ARROW:
6780                 case TV_BOLT:
6781                 {
6782                         do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
6783                         break;
6784                 }
6785
6786                 /* Activate an artifact */
6787                 default:
6788                 {
6789                         do_cmd_activate_aux(item);
6790                         break;
6791                 }
6792         }
6793 }
6794
6795 static int select_magic_eater(bool only_browse)
6796 {
6797         int ext=0;
6798         char choice;
6799         bool flag, request_list;
6800         int tval = 0;
6801         int             ask = TRUE, i = 0;
6802         char            out_val[160];
6803
6804         int menu_line = (use_menu ? 1 : 0);
6805
6806 #ifdef ALLOW_REPEAT
6807         int sn;
6808         if (repeat_pull(&sn))
6809         {
6810                 /* Verify the spell */
6811                 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))
6812                         return sn;
6813                 else if (sn < EATER_EXT*2 && !(p_ptr->magic_num1[sn] < EATER_CHARGE))
6814                         return sn;
6815         }
6816         
6817 #endif /* ALLOW_REPEAT */
6818
6819         for (i = 0; i < 108; i++)
6820         {
6821                 if (p_ptr->magic_num2[i]) break;
6822         }
6823         if (i == 108)
6824         {
6825 #ifdef JP
6826                 msg_print("ËâË¡¤ò³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
6827 #else
6828                 msg_print("You don't have any magic!");
6829 #endif
6830                 return -1;
6831         }
6832
6833         if (use_menu)
6834         {
6835                 screen_save();
6836
6837                 while(!tval)
6838                 {
6839 #ifdef JP
6840                         prt(format(" %s ¾ó", (menu_line == 1) ? "¡Õ" : "  "), 2, 14);
6841                         prt(format(" %s ËâË¡ËÀ", (menu_line == 2) ? "¡Õ" : "  "), 3, 14);
6842                         prt(format(" %s ¥í¥Ã¥É", (menu_line == 3) ? "¡Õ" : "  "), 4, 14);
6843                         prt("¤É¤Î¼ïÎà¤ÎËâË¡¤ò»È¤¤¤Þ¤¹¤«¡©", 0, 0);
6844 #else
6845                         prt(format(" %s staff", (menu_line == 1) ? "> " : "  "), 2, 14);
6846                         prt(format(" %s wand", (menu_line == 2) ? "> " : "  "), 3, 14);
6847                         prt(format(" %s rod", (menu_line == 3) ? "> " : "  "), 4, 14);
6848                         prt("Which type of magic do you use?", 0, 0);
6849 #endif
6850                         choice = inkey();
6851                         switch(choice)
6852                         {
6853                         case ESCAPE:
6854                         case 'z':
6855                         case 'Z':
6856                                 screen_load();
6857                                 return -1;
6858                         case '2':
6859                         case 'j':
6860                         case 'J':
6861                                 menu_line++;
6862                                 break;
6863                         case '8':
6864                         case 'k':
6865                         case 'K':
6866                                 menu_line+= 2;
6867                                 break;
6868                         case '\r':
6869                         case 'x':
6870                         case 'X':
6871                                 ext = (menu_line-1)*EATER_EXT;
6872                                 if (menu_line == 1) tval = TV_STAFF;
6873                                 else if (menu_line == 2) tval = TV_WAND;
6874                                 else tval = TV_ROD;
6875                                 break;
6876                         }
6877                         if (menu_line > 3) menu_line -= 3;
6878                 }
6879                 screen_load();
6880         }
6881         else
6882         {
6883         while (TRUE)
6884         {
6885 #ifdef JP
6886                 if (!get_com("[A] ¾ó, [B] ËâË¡ËÀ, [C] ¥í¥Ã¥É:", &choice, TRUE))
6887 #else
6888                 if (!get_com("[A] staff, [B] wand, [C] rod:", &choice, TRUE))
6889 #endif
6890                 {
6891                         return -1;
6892                 }
6893                 if (choice == 'A' || choice == 'a')
6894                 {
6895                         ext = 0;
6896                         tval = TV_STAFF;
6897                         break;
6898                 }
6899                 if (choice == 'B' || choice == 'b')
6900                 {
6901                         ext = EATER_EXT;
6902                         tval = TV_WAND;
6903                         break;
6904                 }
6905                 if (choice == 'C' || choice == 'c')
6906                 {
6907                         ext = EATER_EXT*2;
6908                         tval = TV_ROD;
6909                         break;
6910                 }
6911         }
6912         }
6913         for (i = ext; i < ext + EATER_EXT; i++)
6914         {
6915                 if (p_ptr->magic_num2[i])
6916                 {
6917                         if (use_menu) menu_line = i-ext+1;
6918                         break;
6919                 }
6920         }
6921         if (i == ext+EATER_EXT)
6922         {
6923 #ifdef JP
6924                 msg_print("¤½¤Î¼ïÎà¤ÎËâË¡¤Ï³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
6925 #else
6926                 msg_print("You don't have that type of magic!");
6927 #endif
6928                 return -1;
6929         }
6930
6931         /* Nothing chosen yet */
6932         flag = FALSE;
6933
6934         /* Build a prompt */
6935 #ifdef JP
6936 (void) strnfmt(out_val, 78, "('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎËâÎϤò»È¤¤¤Þ¤¹¤«¡©");
6937 #else
6938         (void)strnfmt(out_val, 78, "(*=List, ESC=exit) Use which power? ");
6939 #endif
6940         
6941         /* Save the screen */
6942         screen_save();
6943
6944         request_list = always_show_list;
6945
6946         /* Get a spell from the user */
6947         while (!flag)
6948         {
6949                 /* Show the list */
6950                 if (request_list || use_menu)
6951                 {
6952                         byte y, x = 0;
6953                         int ctr, chance;
6954                         int k_idx;
6955                         char dummy[80];
6956                         int x1, y1, level;
6957                         byte col;
6958
6959                         strcpy(dummy, "");
6960
6961                         for (y = 1; y < 20; y++)
6962                                 prt("", y, x);
6963
6964                         y = 1;
6965
6966                         /* Print header(s) */
6967 #ifdef JP
6968                         prt(format("                           %s ¼ºÎ¨                           %s ¼ºÎ¨", (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô"), (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô")), y++, x);
6969 #else
6970                         prt(format("                           %s Fail                           %s Fail", (tval == TV_ROD ? "  Stat  " : " Charges"), (tval == TV_ROD ? "  Stat  " : " Charges")), y++, x);
6971 #endif
6972
6973                         /* Print list */
6974                         for (ctr = 0; ctr < EATER_EXT; ctr++)
6975                         {
6976                                 if (!p_ptr->magic_num2[ctr+ext]) continue;
6977
6978                                 k_idx = lookup_kind(tval, ctr);
6979
6980                                 if (use_menu)
6981                                 {
6982                                         if (ctr == (menu_line-1))
6983 #ifdef JP
6984                                                 strcpy(dummy, "¡Õ");
6985 #else
6986                                         strcpy(dummy, "> ");
6987 #endif
6988                                         else strcpy(dummy, "  ");
6989                                                 
6990                                 }
6991                                 /* letter/number for power selection */
6992                                 else
6993                                 {
6994                                         char letter;
6995                                         if (ctr < 26)
6996                                                 letter = I2A(ctr);
6997                                         else
6998                                                 letter = '0' + ctr - 26;
6999                                         sprintf(dummy, "%c)",letter);
7000                                 }
7001                                 x1 = ((ctr < EATER_EXT/2) ? x : x + 40);
7002                                 y1 = ((ctr < EATER_EXT/2) ? y + ctr : y + ctr - EATER_EXT/2);
7003                                 level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
7004                                 chance = level * 4 / 5 + 20;
7005                                 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
7006                                 level /= 2;
7007                                 if (p_ptr->lev > level)
7008                                 {
7009                                         chance -= 3 * (p_ptr->lev - level);
7010                                 }
7011                                 chance = mod_spell_chance_1(chance);
7012                                 chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
7013                                 /* Stunning makes spells harder */
7014                                 if (p_ptr->stun > 50) chance += 25;
7015                                 else if (p_ptr->stun) chance += 15;
7016
7017                                 if (chance > 95) chance = 95;
7018
7019                                 chance = mod_spell_chance_2(chance);
7020
7021                                 col = TERM_WHITE;
7022
7023                                 if (k_idx)
7024                                 {
7025                                         if (tval == TV_ROD)
7026                                         {
7027                                                 strcat(dummy, format(
7028 #ifdef JP
7029                                                                " %-22.22s ½¼Å¶:%2d/%2d%3d%%",
7030 #else
7031                                                                " %-22.22s   (%2d/%2d) %3d%%",
7032 #endif
7033                                                                k_name + k_info[k_idx].name, 
7034                                                                p_ptr->magic_num1[ctr+ext] ? 
7035                                                                (p_ptr->magic_num1[ctr+ext] - 1) / (EATER_ROD_CHARGE * k_info[k_idx].pval) +1 : 0, 
7036                                                                p_ptr->magic_num2[ctr+ext], chance));
7037                                                 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;
7038                                         }
7039                                         else
7040                                         {
7041                                                 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));
7042                                                 if (p_ptr->magic_num1[ctr+ext] < EATER_CHARGE) col = TERM_RED;
7043                                         }
7044                                 }
7045                                 else
7046                                         strcpy(dummy, "");
7047                                 c_prt(col, dummy, y1, x1);
7048                         }
7049                 }
7050
7051                 if (!get_com(out_val, &choice, FALSE)) break;
7052
7053                 if (use_menu && choice != ' ')
7054                 {
7055                         switch (choice)
7056                         {
7057                                 case '0':
7058                                 {
7059                                         screen_load();
7060                                         return 0;
7061                                 }
7062
7063                                 case '8':
7064                                 case 'k':
7065                                 case 'K':
7066                                 {
7067                                         do
7068                                         {
7069                                                 menu_line += EATER_EXT - 1;
7070                                                 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
7071                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
7072                                         break;
7073                                 }
7074
7075                                 case '2':
7076                                 case 'j':
7077                                 case 'J':
7078                                 {
7079                                         do
7080                                         {
7081                                                 menu_line++;
7082                                                 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
7083                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
7084                                         break;
7085                                 }
7086
7087                                 case '4':
7088                                 case 'h':
7089                                 case 'H':
7090                                 case '6':
7091                                 case 'l':
7092                                 case 'L':
7093                                 {
7094                                         bool reverse = FALSE;
7095                                         if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
7096                                         if (menu_line > EATER_EXT/2)
7097                                         {
7098                                                 menu_line -= EATER_EXT/2;
7099                                                 reverse = TRUE;
7100                                         }
7101                                         else menu_line+=EATER_EXT/2;
7102                                         while(!p_ptr->magic_num2[menu_line+ext-1])
7103                                         {
7104                                                 if (reverse)
7105                                                 {
7106                                                         menu_line--;
7107                                                         if (menu_line < 2) reverse = FALSE;
7108                                                 }
7109                                                 else
7110                                                 {
7111                                                         menu_line++;
7112                                                         if (menu_line > EATER_EXT-1) reverse = TRUE;
7113                                                 }
7114                                         }
7115                                         break;
7116                                 }
7117
7118                                 case 'x':
7119                                 case 'X':
7120                                 case '\r':
7121                                 {
7122                                         i = menu_line - 1;
7123                                         ask = FALSE;
7124                                         break;
7125                                 }
7126                         }
7127                 }
7128
7129                 /* Request redraw */
7130                 if (use_menu && ask) continue;
7131
7132                 /* Request redraw */
7133                 if (!use_menu && ((choice == ' ') || (choice == '*') || (choice == '?')))
7134                 {
7135                         /* Hide the list */
7136                         if (request_list)
7137                         {
7138                                 /* Hide list */
7139                                 request_list = FALSE;
7140                                 
7141                                 /* Restore the screen */
7142                                 screen_load();
7143                                 screen_save();
7144                         }
7145                         else
7146                                 request_list = TRUE;
7147
7148                         /* Redo asking */
7149                         continue;
7150                 }
7151
7152                 if (!use_menu)
7153                 {
7154                         if (isalpha(choice))
7155                         {
7156                                 /* Note verify */
7157                                 ask = (isupper(choice));
7158
7159                                 /* Lowercase */
7160                                 if (ask) choice = tolower(choice);
7161
7162                                 /* Extract request */
7163                                 i = (islower(choice) ? A2I(choice) : -1);
7164                         }
7165                         else
7166                         {
7167                                 ask = FALSE; /* Can't uppercase digits */
7168
7169                                 i = choice - '0' + 26;
7170                         }
7171                 }
7172
7173                 /* Totally Illegal */
7174                 if ((i < 0) || (i > EATER_EXT) || !p_ptr->magic_num2[i+ext])
7175                 {
7176                         bell();
7177                         continue;
7178                 }
7179
7180                 if (!only_browse)
7181                 {
7182                         /* Verify it */
7183                         if (ask)
7184                         {
7185                                 char tmp_val[160];
7186
7187                                 /* Prompt */
7188 #ifdef JP
7189                                 (void) strnfmt(tmp_val, 78, "%s¤ò»È¤¤¤Þ¤¹¤«¡© ", k_name + k_info[lookup_kind(tval ,i)].name);
7190 #else
7191                                 (void) strnfmt(tmp_val, 78, "Use %s?", k_name + k_info[lookup_kind(tval ,i)].name);
7192 #endif
7193
7194                                 /* Belay that order */
7195                                 if (!get_check(tmp_val)) continue;
7196                         }
7197                         if (tval == TV_ROD)
7198                         {
7199                                 if (p_ptr->magic_num1[ext+i]  > k_info[lookup_kind(tval, i)].pval * (p_ptr->magic_num2[ext+i] - 1) * EATER_ROD_CHARGE)
7200                                 {
7201 #ifdef JP
7202                                         msg_print("¤½¤ÎËâË¡¤Ï¤Þ¤À½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
7203 #else
7204                                         msg_print("The magic are still charging.");
7205 #endif
7206                                         msg_print(NULL);
7207                                         if (use_menu) ask = TRUE;
7208                                         continue;
7209                                 }
7210                         }
7211                         else
7212                         {
7213                                 if (p_ptr->magic_num1[ext+i] < EATER_CHARGE)
7214                                 {
7215 #ifdef JP
7216                                         msg_print("¤½¤ÎËâË¡¤Ï»ÈÍѲó¿ô¤¬ÀÚ¤ì¤Æ¤¤¤ë¡£");
7217 #else
7218                                         msg_print("The magic has no charges left.");
7219 #endif
7220                                         msg_print(NULL);
7221                                         if (use_menu) ask = TRUE;
7222                                         continue;
7223                                 }
7224                         }
7225                 }
7226
7227                 /* Browse */
7228                 else
7229                 {
7230                         int line, j;
7231                         char temp[70 * 20];
7232
7233                         /* Clear lines, position cursor  (really should use strlen here) */
7234                         Term_erase(7, 23, 255);
7235                         Term_erase(7, 22, 255);
7236                         Term_erase(7, 21, 255);
7237                         Term_erase(7, 20, 255);
7238
7239                         roff_to_buf(k_text + k_info[lookup_kind(tval, i)].text, 62, temp, sizeof(temp));
7240                         for (j = 0, line = 21; temp[j]; j += 1 + strlen(&temp[j]))
7241                         {
7242                                 prt(&temp[j], line, 10);
7243                                 line++;
7244                         }
7245         
7246 #ifdef JP
7247                         prt("²¿¤«¥­¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£",0,0);
7248 #else
7249                         prt("Hit any key.",0,0);
7250 #endif
7251                         (void)inkey();
7252                         continue;
7253                 }
7254
7255                 /* Stop the loop */
7256                 flag = TRUE;
7257         }
7258
7259         /* Restore the screen */
7260         screen_load();
7261
7262         if (!flag) return -1;
7263
7264 #ifdef ALLOW_REPEAT
7265         repeat_push(ext+i);
7266 #endif /* ALLOW_REPEAT */
7267         return ext+i;
7268 }
7269
7270
7271 /*
7272  *  Use eaten rod, wand or staff
7273  */
7274 void do_cmd_magic_eater(bool only_browse)
7275 {
7276         int item, chance, level, k_idx, tval, sval;
7277         bool use_charge = TRUE;
7278
7279         /* Not when confused */
7280         if (!only_browse && p_ptr->confused)
7281         {
7282 #ifdef JP
7283 msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
7284 #else
7285                 msg_print("You are too confused!");
7286 #endif
7287
7288                 return;
7289         }
7290
7291         item = select_magic_eater(only_browse);
7292         if (item == -1)
7293         {
7294                 energy_use = 0;
7295                 return;
7296         }
7297         if (item >= EATER_EXT*2) {tval = TV_ROD;sval = item - EATER_EXT*2;}
7298         else if (item >= EATER_EXT) {tval = TV_WAND;sval = item - EATER_EXT;}
7299         else {tval = TV_STAFF;sval = item;}
7300         k_idx = lookup_kind(tval, sval);
7301
7302         level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
7303         chance = level * 4 / 5 + 20;
7304         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
7305         level /= 2;
7306         if (p_ptr->lev > level)
7307         {
7308                 chance -= 3 * (p_ptr->lev - level);
7309         }
7310         chance = mod_spell_chance_1(chance);
7311         chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
7312         /* Stunning makes spells harder */
7313         if (p_ptr->stun > 50) chance += 25;
7314         else if (p_ptr->stun) chance += 15;
7315
7316         if (chance > 95) chance = 95;
7317
7318         chance = mod_spell_chance_2(chance);
7319
7320         if (randint0(100) < chance)
7321         {
7322                 if (flush_failure) flush();
7323
7324 #ifdef JP
7325 msg_print("¼öʸ¤ò¤¦¤Þ¤¯¾§¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡ª");
7326 #else
7327                 msg_format("You failed to get the magic off!");
7328 #endif
7329
7330                 sound(SOUND_FAIL);
7331                 if (randint1(100) >= chance)
7332                         chg_virtue(V_CHANCE,-1);
7333                 energy_use = 100;
7334
7335                 return;
7336         }
7337         else
7338         {
7339                 int dir = 0;
7340
7341                 if (tval == TV_ROD)
7342                 {
7343                         if ((sval >= SV_ROD_MIN_DIRECTION) && (sval != SV_ROD_HAVOC) && (sval != SV_ROD_AGGRAVATE) && (sval != SV_ROD_PESTICIDE))
7344                                 if (!get_aim_dir(&dir)) return;
7345                         rod_effect(sval, dir, &use_charge, TRUE);
7346                         if (!use_charge) return;
7347                 }
7348                 else if (tval == TV_WAND)
7349                 {
7350                         if (!get_aim_dir(&dir)) return;
7351                         wand_effect(sval, dir, TRUE);
7352                 }
7353                 else
7354                 {
7355                         staff_effect(sval, &use_charge, TRUE, TRUE);
7356                         if (!use_charge) return;
7357                 }
7358                 if (randint1(100) < chance)
7359                         chg_virtue(V_CHANCE,1);
7360         }
7361         energy_use = 100;
7362         if (tval == TV_ROD) p_ptr->magic_num1[item] += k_info[k_idx].pval * EATER_ROD_CHARGE;
7363         else p_ptr->magic_num1[item] -= EATER_CHARGE;
7364 }