OSDN Git Service

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