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