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_hero(randint1(25) + 25, FALSE);
4479                                 (void)hp_player(777);
4480                                 o_ptr->timeout = 300;
4481                                 break;
4482                         }
4483
4484                         case ART_JULIAN:
4485                         {
4486 #ifdef JP
4487                                 msg_print("³»¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4488 #else
4489                                 msg_print("Your armor glows deep blue...");
4490 #endif
4491
4492                                 (void)symbol_genocide(200, TRUE);
4493                                 o_ptr->timeout = 500;
4494                                 break;
4495                         }
4496
4497                         case ART_CASPANION:
4498                         {
4499 #ifdef JP
4500                                 msg_print("³»¤¬ÀÖ¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4501 #else
4502                                 msg_print("Your armor glows bright red...");
4503 #endif
4504
4505                                 destroy_doors_touch();
4506                                 o_ptr->timeout = 10;
4507                                 break;
4508                         }
4509
4510                         case ART_DOR:
4511                         case ART_TERROR:
4512                         case ART_STONEMASK:
4513                         {
4514                                 turn_monsters(40 + p_ptr->lev);
4515                                 o_ptr->timeout = 3 * (p_ptr->lev + 10);
4516
4517                                 break;
4518                         }
4519
4520                         case ART_HOLHENNETH:
4521                         {
4522 #ifdef JP
4523                                 msg_print("¥Ø¥ë¥á¥Ã¥È¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4524                                 msg_print("¿´¤Ë¥¤¥á¡¼¥¸¤¬É⤫¤ó¤Ç¤­¤¿...");
4525 #else
4526                                 msg_print("Your helm glows bright white...");
4527                                 msg_print("An image forms in your mind...");
4528 #endif
4529
4530                                 detect_all(DETECT_RAD_DEFAULT);
4531                                 o_ptr->timeout = randint0(55) + 55;
4532                                 break;
4533                         }
4534
4535                         case ART_AMBER:
4536                         {
4537 #ifdef JP
4538                                 msg_print("²¦´§¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4539                                 msg_print("ÂÎÆâ¤ËÃȤ«¤¤¸ÝÆ°¤¬´¶¤¸¤é¤ì¤ë...");
4540 #else
4541                                 msg_print("Your crown glows deep blue...");
4542                                 msg_print("You feel a warm tingling inside...");
4543 #endif
4544
4545                                 (void)hp_player(700);
4546                                 (void)set_cut(0);
4547                                 o_ptr->timeout = 250;
4548                                 break;
4549                         }
4550
4551                         case ART_COLLUIN:
4552                         case ART_SEIRYU:
4553                         {
4554 #ifdef JP
4555                                 msg_format("%s¤¬ÍÍ¡¹¤Ê¿§¤Ëµ±¤¤¤¿...", o_ptr->name1 == ART_COLLUIN ? "¥¯¥í¡¼¥¯" : "³»");
4556 #else
4557                                 msg_format("Your %s glows many colours...", o_ptr->name1 == ART_COLLUIN ? "cloak" : "armor");
4558 #endif
4559
4560                                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
4561                                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
4562                                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
4563                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
4564                                 (void)set_oppose_pois(randint1(20) + 20, FALSE);
4565                                 o_ptr->timeout = 111;
4566                                 break;
4567                         }
4568
4569                         case ART_HOLCOLLETH:
4570                         {
4571 #ifdef JP
4572                                 msg_print("¥¯¥í¡¼¥¯¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4573 #else
4574                                 msg_print("Your cloak glows deep blue...");
4575 #endif
4576
4577                                 sleep_monsters_touch();
4578                                 o_ptr->timeout = 55;
4579                                 break;
4580                         }
4581
4582                         case ART_THINGOL:
4583                         {
4584 #ifdef JP
4585                                 msg_print("¥¯¥í¡¼¥¯¤¬²«¿§¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4586 #else
4587                                 msg_print("Your cloak glows bright yellow...");
4588 #endif
4589
4590                                 recharge(130);
4591                                 o_ptr->timeout = 70;
4592                                 break;
4593                         }
4594
4595                         case ART_COLANNON:
4596                         {
4597 #ifdef JP
4598                                 msg_print("¥¯¥í¡¼¥¯¤¬ÊÕ¤ê¤Î¶õ´Ö¤ò¤æ¤¬¤Þ¤»¤¿...");
4599 #else
4600                                 msg_print("Your cloak twists space around you...");
4601 #endif
4602
4603                                 teleport_player(100, 0L);
4604                                 o_ptr->timeout = 45;
4605                                 break;
4606                         }
4607
4608                         case ART_LUTHIEN:
4609                         {
4610 #ifdef JP
4611                                 msg_print("¥¯¥í¡¼¥¯¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
4612 #else
4613                                 msg_print("Your cloak glows a deep red...");
4614 #endif
4615
4616                                 restore_level();
4617                                 o_ptr->timeout = 450;
4618                                 break;
4619                         }
4620
4621                         case ART_CAMMITHRIM:
4622                         {
4623 #ifdef JP
4624                                 msg_print("¥°¥í¡¼¥Ö¤¬âÁ¤·¤¤¤¯¤é¤¤¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
4625 #else
4626                                 msg_print("Your gloves glow extremely brightly...");
4627 #endif
4628
4629                                 if (!get_aim_dir(&dir)) return;
4630                                 fire_bolt(GF_MISSILE, dir, damroll(2, 6));
4631                                 o_ptr->timeout = 2;
4632                                 break;
4633                         }
4634
4635                         case ART_PAURHACH:
4636                         {
4637 #ifdef JP
4638                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬±ê¤Ëʤ¤ï¤ì¤¿...");
4639 #else
4640                                 msg_print("Your gauntlets are covered in fire...");
4641 #endif
4642
4643                                 if (!get_aim_dir(&dir)) return;
4644                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
4645                                 o_ptr->timeout = randint0(8) + 8;
4646                                 break;
4647                         }
4648
4649                         case ART_PAURNIMMEN:
4650                         {
4651 #ifdef JP
4652                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4653 #else
4654                                 msg_print("Your gauntlets are covered in frost...");
4655 #endif
4656
4657                                 if (!get_aim_dir(&dir)) return;
4658                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
4659                                 o_ptr->timeout = randint0(7) + 7;
4660                                 break;
4661                         }
4662
4663                         case ART_PAURAEGEN:
4664                         {
4665 #ifdef JP
4666                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬²Ð²Ö¤Ëʤ¤ï¤ì¤¿...");
4667 #else
4668                                 msg_print("Your gauntlets are covered in sparks...");
4669 #endif
4670
4671                                 if (!get_aim_dir(&dir)) return;
4672                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
4673                                 o_ptr->timeout = randint0(5) + 5;
4674                                 break;
4675                         }
4676
4677                         case ART_PAURNEN:
4678                         {
4679 #ifdef JP
4680                                 msg_print("¥¬¥ó¥È¥ì¥Ã¥È¤¬»À¤Ëʤ¤ï¤ì¤¿...");
4681 #else
4682                                 msg_print("Your gauntlets are covered in acid...");
4683 #endif
4684
4685                                 if (!get_aim_dir(&dir)) return;
4686                                 fire_bolt(GF_ACID, dir, damroll(5, 8));
4687                                 o_ptr->timeout = randint0(6) + 6;
4688                                 break;
4689                         }
4690
4691                         case ART_FINGOLFIN:
4692                         {
4693 #ifdef JP
4694                                 msg_print("¥»¥¹¥¿¥¹¤ËËâË¡¤Î¥È¥²¤¬¸½¤ì¤¿...");
4695 #else
4696                                 msg_print("Your cesti grows magical spikes...");
4697 #endif
4698
4699                                 if (!get_aim_dir(&dir)) return;
4700                                 fire_bolt(GF_ARROW, dir, 150);
4701                                 o_ptr->timeout = randint0(90) + 90;
4702                                 break;
4703                         }
4704
4705                         case ART_FEANOR:
4706                         {
4707 #ifdef JP
4708                                 msg_print("¥Ö¡¼¥Ä¤¬¥°¥ê¡¼¥ó¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
4709 #else
4710                                 msg_print("Your boots glow bright green...");
4711 #endif
4712
4713                                 (void)set_fast(randint1(20) + 20, FALSE);
4714                                 o_ptr->timeout = 200;
4715                                 break;
4716                         }
4717
4718                         case ART_FLORA:
4719                         {
4720 #ifdef JP
4721                                 msg_print("¥Ö¡¼¥Ä¤¬¿¼¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
4722 #else
4723                                 msg_print("Your boots glow deep blue...");
4724 #endif
4725
4726                                 (void)set_afraid(0);
4727                                 (void)set_poisoned(0);
4728                                 o_ptr->timeout = 5;
4729                                 break;
4730                         }
4731
4732                         case ART_NARTHANC:
4733                         {
4734 #ifdef JP
4735                                 msg_print("¥À¥¬¡¼¤¬±ê¤Ëʤ¤ï¤ì¤¿...");
4736 #else
4737                                 msg_print("Your dagger is covered in fire...");
4738 #endif
4739
4740                                 if (!get_aim_dir(&dir)) return;
4741                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
4742                                 o_ptr->timeout = randint0(8) + 8;
4743                                 break;
4744                         }
4745
4746                         case ART_NIMTHANC:
4747                         {
4748 #ifdef JP
4749                                 msg_print("¥À¥¬¡¼¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4750 #else
4751                                 msg_print("Your dagger is covered in frost...");
4752 #endif
4753
4754                                 if (!get_aim_dir(&dir)) return;
4755                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
4756                                 o_ptr->timeout = randint0(7) + 7;
4757                                 break;
4758                         }
4759
4760                         case ART_DETHANC:
4761                         {
4762 #ifdef JP
4763                                 msg_print("¥À¥¬¡¼¤¬²Ð²Ö¤Ëʤ¤ï¤ì¤¿...");
4764 #else
4765                                 msg_print("Your dagger is covered in sparks...");
4766 #endif
4767
4768                                 if (!get_aim_dir(&dir)) return;
4769                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
4770                                 o_ptr->timeout = randint0(5) + 5;
4771                                 break;
4772                         }
4773
4774                         case ART_RILIA:
4775                         {
4776 #ifdef JP
4777                                 msg_print("¥À¥¬¡¼¤¬¿¼¤¤Îп§¤Ë¸ÝÆ°¤·¤Æ¤¤¤ë...");
4778 #else
4779                                 msg_print("Your dagger throbs deep green...");
4780 #endif
4781
4782                                 if (!get_aim_dir(&dir)) return;
4783                                 fire_ball(GF_POIS, dir, 12, 3);
4784                                 o_ptr->timeout = randint0(4) + 4;
4785                                 break;
4786                         }
4787
4788                         case ART_NUMAHOKO:
4789                         {
4790 #ifdef JP
4791                                 msg_print("Ì·¤¬¿¼¤¤ÀÄ¿§¤Ë¸ÝÆ°¤·¤Æ¤¤¤ë...");
4792 #else
4793                                 msg_print("Your dagger throbs deep blue...");
4794 #endif
4795
4796                                 if (!get_aim_dir(&dir)) return;
4797                                 fire_ball(GF_WATER, dir, 200, 3);
4798                                 o_ptr->timeout = 250;
4799                                 break;
4800                         }
4801
4802                         case ART_FIONA:
4803                         {
4804 #ifdef JP
4805                                 msg_print("¥À¥¬¡¼¤¬Î䵤¤Ëʤ¤ï¤ì¤¿...");
4806 #else
4807                                 msg_print("Your dagger is covered in frost...");
4808 #endif
4809
4810                                 if (!get_aim_dir(&dir)) return;
4811                                 fire_ball(GF_COLD, dir, 48, 2);
4812                                 o_ptr->timeout = randint0(5) + 5;
4813                                 break;
4814                         }
4815
4816                         case ART_KUSANAGI:
4817                         case ART_WEREWINDLE:
4818                         {
4819                                 switch (randint1(13))
4820                                 {
4821                                 case 1: case 2: case 3: case 4: case 5:
4822                                         teleport_player(10, 0L);
4823                                         break;
4824                                 case 6: case 7: case 8: case 9: case 10:
4825                                         teleport_player(222, 0L);
4826                                         break;
4827                                 case 11: case 12:
4828                                         (void)stair_creation();
4829                                         break;
4830                                 default:
4831 #ifdef JP
4832 if (get_check("¤³¤Î³¬¤òµî¤ê¤Þ¤¹¤«¡©"))
4833 #else
4834                                         if (get_check("Leave this level? "))
4835 #endif
4836
4837                                         {
4838                                                 if (autosave_l) do_cmd_save_game(TRUE);
4839
4840                                                 /* Leaving */
4841                                                 p_ptr->leaving = TRUE;
4842                                         }
4843                                 }
4844                                 o_ptr->timeout = 35;
4845                                 break;
4846                         }
4847
4848                         case ART_KAMUI:
4849                         {
4850                                 teleport_player(222, 0L);
4851                                 o_ptr->timeout = 25;
4852                                 break;
4853                         }
4854
4855                         case ART_RINGIL:
4856                         {
4857 #ifdef JP
4858                                 msg_print("¥½¡¼¥É¤¬ÀĤ¯·ã¤·¤¯µ±¤¤¤¿...");
4859 #else
4860                                 msg_print("Your sword glows an intense blue...");
4861 #endif
4862
4863                                 if (!get_aim_dir(&dir)) return;
4864                                 fire_ball(GF_COLD, dir, 100, 2);
4865                                 o_ptr->timeout = 200;
4866                                 break;
4867                         }
4868
4869                         case ART_DAWN:
4870                         {
4871 #ifdef JP
4872 msg_print("¶Ç¤Î»ÕÃĤò¾¤´­¤·¤¿¡£");
4873 #else
4874                                 msg_print("You summon the Legion of the Dawn.");
4875 #endif
4876
4877                                 (void)summon_specific(-1, py, px, dun_level, SUMMON_DAWN, (PM_ALLOW_GROUP | PM_FORCE_PET));
4878                                 o_ptr->timeout = 500 + randint1(500);
4879                                 break;
4880                         }
4881
4882                         case ART_ANDURIL:
4883                         {
4884 #ifdef JP
4885                                 msg_print("¥½¡¼¥É¤¬ÀÖ¤¯·ã¤·¤¯µ±¤¤¤¿...");
4886 #else
4887                                 msg_print("Your sword glows an intense red...");
4888 #endif
4889
4890                                 if (!get_aim_dir(&dir)) return;
4891                                 fire_ball(GF_FIRE, dir, 72, 2);
4892                                 o_ptr->timeout = 400;
4893                                 break;
4894                         }
4895
4896                         case ART_THEODEN:
4897                         {
4898 #ifdef JP
4899                                  msg_print("¥¢¥Ã¥¯¥¹¤Î¿Ï¤¬¹õ¤¯µ±¤¤¤¿...");
4900 #else
4901                                 msg_print("Your axe blade glows black...");
4902 #endif
4903
4904                                 if (!get_aim_dir(&dir)) return;
4905                                 drain_life(dir, 120);
4906                                 o_ptr->timeout = 400;
4907                                 break;
4908                         }
4909
4910                         case ART_RUNESPEAR:
4911                         {
4912 #ifdef JP
4913 msg_print("¤¢¤Ê¤¿¤ÎÁä¤ÏÅŵ¤¤Ç¥¹¥Ñ¡¼¥¯¤·¤Æ¤¤¤ë...");
4914 #else
4915                                 msg_print("Your spear crackles with electricity...");
4916 #endif
4917
4918                                 if (!get_aim_dir(&dir)) return;
4919                                 fire_ball(GF_ELEC, dir, 100, 3);
4920                                 o_ptr->timeout = 200;
4921                                 break;
4922                         }
4923
4924                         case ART_AEGLOS:
4925                         {
4926 #ifdef JP
4927                                 msg_print("¥¹¥Ô¥¢¤¬Çò¤¯ÌÀ¤ë¤¯µ±¤¤¤¿...");
4928 #else
4929                                 msg_print("Your spear glows a bright white...");
4930 #endif
4931
4932                                 if (!get_aim_dir(&dir)) return;
4933                                 fire_ball(GF_COLD, dir, 100, 3);
4934                                 o_ptr->timeout = 200;
4935                                 break;
4936                         }
4937
4938                         case ART_DESTINY:
4939                         {
4940 #ifdef JP
4941                                 msg_print("¥¹¥Ô¥¢¤¬¸ÝÆ°¤·¤¿...");
4942 #else
4943                                 msg_print("Your spear pulsates...");
4944 #endif
4945
4946                                 if (!get_aim_dir(&dir)) return;
4947                                 wall_to_mud(dir);
4948                                 o_ptr->timeout = 5;
4949                                 break;
4950                         }
4951
4952                         case ART_NAIN:
4953                         {
4954 #ifdef JP
4955                                 msg_print("¤Ä¤ë¤Ï¤·¤¬¸ÝÆ°¤·¤¿...");
4956 #else
4957                                 msg_print("Your mattock pulsates...");
4958 #endif
4959
4960                                 if (!get_aim_dir(&dir)) return;
4961                                 wall_to_mud(dir);
4962                                 o_ptr->timeout = 2;
4963                                 break;
4964                         }
4965
4966                         case ART_EONWE:
4967                         {
4968 #ifdef JP
4969                                 msg_print("¥¢¥Ã¥¯¥¹¤«¤é¤Ò¤É¤¯±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
4970 #else
4971                                 msg_print("Your axe lets out a long, shrill note...");
4972 #endif
4973
4974                                 (void)mass_genocide(200, TRUE);
4975                                 o_ptr->timeout = 1000;
4976                                 break;
4977                         }
4978
4979                         case ART_LOTHARANG:
4980                         {
4981 #ifdef JP
4982                                 msg_print("¥Ð¥È¥ë¡¦¥¢¥Ã¥¯¥¹¤¬¿¼»ç¤Î¸÷¤òÊü¼Í¤·¤¿...");
4983 #else
4984                                 msg_print("Your battle axe radiates deep purple...");
4985 #endif
4986
4987                                 hp_player(damroll(4, 8));
4988                                 (void)set_cut((p_ptr->cut / 2) - 50);
4989                                 o_ptr->timeout = randint0(3) + 3;
4990                                 break;
4991                         }
4992
4993                         case ART_ULMO:
4994                         {
4995 #ifdef JP
4996                                 msg_print("¥È¥é¥¤¥Ç¥ó¥È¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
4997 #else
4998                                 msg_print("Your trident glows deep red...");
4999 #endif
5000
5001                                 if (!get_aim_dir(&dir)) return;
5002                                 teleport_monster(dir);
5003                                 o_ptr->timeout = 150;
5004                                 break;
5005                         }
5006
5007                         case ART_AVAVIR:
5008                         {
5009 #ifdef JP
5010                                 msg_print("Âç³ù¤¬½À¤é¤«¤¯Çò¤¯µ±¤¤¤¿...");
5011 #else
5012                                 msg_print("Your scythe glows soft white...");
5013 #endif
5014                                 if (!word_of_recall()) return;
5015                                 o_ptr->timeout = 200;
5016                                 break;
5017                         }
5018
5019                         case ART_MAGATAMA:
5020                         {
5021 #ifdef JP
5022                                 msg_print("¸û¶Ì¤¬½À¤é¤«¤¯Çò¤¯µ±¤¤¤¿...");
5023 #else
5024                                 msg_print("Your scythe glows soft white...");
5025 #endif
5026                                 if (!word_of_recall()) return;
5027                                 o_ptr->timeout = 200;
5028                                 break;
5029                         }
5030
5031                         case ART_TOTILA:
5032                         {
5033 #ifdef JP
5034                                 msg_print("¥Õ¥ì¥¤¥ë¤¬ÍÍ¡¹¤Ê¿§¤Î²Ð²Ö¤òȯ¤·¤¿...");
5035 #else
5036                                 msg_print("Your flail glows in scintillating colours...");
5037 #endif
5038
5039                                 if (!get_aim_dir(&dir)) return;
5040                                 confuse_monster(dir, 20);
5041                                 o_ptr->timeout = 15;
5042                                 break;
5043                         }
5044
5045                         case ART_FIRESTAR:
5046                         {
5047 #ifdef JP
5048                                 msg_print("¥â¡¼¥Ë¥ó¥°¥¹¥¿¡¼¤«¤é±ê¤¬¿á¤­½Ð¤·¤¿...");
5049 #else
5050                                 msg_print("Your morning star rages in fire...");
5051 #endif
5052
5053                                 if (!get_aim_dir(&dir)) return;
5054                                 fire_ball(GF_FIRE, dir, 72, 3);
5055                                 o_ptr->timeout = 100;
5056                                 break;
5057                         }
5058
5059                         case ART_GOTHMOG:
5060                         {
5061 #ifdef JP
5062                                 msg_print("¥à¥Á¤¬¿¼¤¤ÀÖ¿§¤Ëµ±¤¤¤¿...");
5063 #else
5064                                 msg_print("Your whip glows deep red...");
5065 #endif
5066
5067                                 if (!get_aim_dir(&dir)) return;
5068                                 fire_ball(GF_FIRE, dir, 120, 3);
5069                                 o_ptr->timeout = 15;
5070                                 break;
5071                         }
5072
5073                         case ART_TARATOL:
5074                         {
5075 #ifdef JP
5076                                 msg_print("¥á¥¤¥¹¤¬¥°¥ê¡¼¥ó¤ËÌÀ¤ë¤¯µ±¤¤¤¿...");
5077 #else
5078                                 msg_print("Your mace glows bright green...");
5079 #endif
5080
5081                                 (void)set_fast(randint1(20) + 20, FALSE);
5082                                 o_ptr->timeout = randint0(100) + 100;
5083                                 break;
5084                         }
5085
5086                         case ART_ERIRIL:
5087                         {
5088 #ifdef JP
5089                                 msg_print("¥¯¥©¡¼¥¿¡¼¥¹¥¿¥Ã¥Õ¤¬²«¿§¤¯µ±¤¤¤¿...");
5090 #else
5091                                 msg_print("Your quarterstaff glows yellow...");
5092 #endif
5093
5094                                 if (!ident_spell(FALSE)) return;
5095                                 o_ptr->timeout = 10;
5096                                 break;
5097                         }
5098
5099                         case ART_GANDALF:
5100                         {
5101 #ifdef JP
5102                                 msg_print("¾ó¤¬ÌÀ¤ë¤¯µ±¤¤¤¿...");
5103 #else
5104                                 msg_print("Your quarterstaff glows brightly...");
5105 #endif
5106
5107                                 detect_all(DETECT_RAD_DEFAULT);
5108                                 probing();
5109                                 identify_fully(FALSE);
5110                                 o_ptr->timeout = 100;
5111                                 break;
5112                         }
5113
5114                         case ART_TURMIL:
5115                         {
5116 #ifdef JP
5117                                 msg_print("¥Ï¥ó¥Þ¡¼¤¬Çò¤¯µ±¤¤¤¿...");
5118 #else
5119                                 msg_print("Your hammer glows white...");
5120 #endif
5121
5122                                 if (!get_aim_dir(&dir)) return;
5123                                 drain_life(dir, 90);
5124                                 o_ptr->timeout = 70;
5125                                 break;
5126                         }
5127
5128                         case ART_BRAND:
5129                         {
5130 #ifdef JP
5131                                 msg_print("¥¯¥í¥¹¥Ü¥¦¤¬¿¼¹È¤Ëµ±¤¤¤¿...");
5132 #else
5133                                 msg_print("Your crossbow glows deep red...");
5134 #endif
5135
5136                                 (void)brand_bolts();
5137                                 o_ptr->timeout = 999;
5138                                 break;
5139                         }
5140                         case ART_CRIMSON:
5141                         {
5142                                 int num = 1;
5143                                 int i;
5144                                 int flg = PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL;
5145                                 int tx, ty;
5146 #ifdef JP
5147                                 msg_print("¤»¤Ã¤«¤¯¤À¤«¤é¡Ø¥¯¥ê¥à¥¾¥ó¡Ù¤ò¤Ö¤Ã¤Ñ¤Ê¤¹¤¼¡ª");
5148 #else
5149                                 msg_print("I'll fire CRIMSON! SEKKAKUDAKARA!");
5150 #endif
5151
5152                                 if (!get_aim_dir(&dir)) return;
5153
5154                                 /* Use the given direction */
5155                                 tx = px + 99 * ddx[dir];
5156                                 ty = py + 99 * ddy[dir];
5157
5158                                 /* Hack -- Use an actual "target" */
5159                                 if ((dir == 5) && target_okay())
5160                                 {
5161                                         tx = target_col;
5162                                         ty = target_row;
5163                                 }
5164
5165                                 if (p_ptr->pclass == CLASS_ARCHER)
5166                                 {
5167                                         /* Extra shot at level 10 */
5168                                         if (p_ptr->lev >= 10) num++;
5169
5170                                         /* Extra shot at level 30 */
5171                                         if (p_ptr->lev >= 30) num++;
5172
5173                                         /* Extra shot at level 45 */
5174                                         if (p_ptr->lev >= 45) num++;
5175                                 }
5176
5177                                 for (i = 0; i < num; i++)
5178                                         project(0, p_ptr->lev/20+1, ty, tx, p_ptr->lev*p_ptr->lev*6/50, GF_ROCKET, flg, -1);
5179                                 o_ptr->timeout = 15;
5180                                 break;
5181                         }
5182                         case ART_PALANTIR:
5183                         {
5184                                 monster_type *m_ptr;
5185                                 monster_race *r_ptr;
5186                                 int i;
5187
5188 #ifdef JP
5189                                 msg_print("´ñ̯¤Ê¾ì½ê¤¬Æ¬¤ÎÃæ¤ËÉ⤫¤ó¤À¡¥¡¥¡¥");
5190 #else
5191                                 msg_print("Some strange places show up in your mind. And you see ...");
5192 #endif
5193
5194                                 /* Process the monsters (backwards) */
5195                                 for (i = m_max - 1; i >= 1; i--)
5196                                 {
5197                                         /* Access the monster */
5198                                         m_ptr = &m_list[i];
5199
5200                                         /* Ignore "dead" monsters */
5201                                         if (!m_ptr->r_idx) continue;
5202
5203                                         r_ptr = &r_info[m_ptr->r_idx];
5204
5205                                         if(r_ptr->flags1 & RF1_UNIQUE)
5206                                         {
5207 #ifdef JP
5208                                                 msg_format("%s¡¥ ",r_name + r_ptr->name);
5209 #else
5210                                                 msg_format("%s. ",r_name + r_ptr->name);
5211 #endif
5212                                         }
5213                                 }
5214                                 o_ptr->timeout = 200;
5215                                 break;
5216                         }
5217
5218                         case ART_STONE_LORE:
5219                         {
5220 #ifdef JP
5221                                 msg_print("ÀФ¬±£¤µ¤ì¤¿ÈëÌ©¤ò¼Ì¤·½Ð¤·¤¿¡¥¡¥¡¥");
5222 #else
5223                                 msg_print("The stone reveals hidden mysteries...");
5224 #endif
5225                                 if (!ident_spell(FALSE)) return;
5226
5227                                 if (mp_ptr->spell_book)
5228                                 {
5229                                         /* Sufficient mana */
5230                                         if (20 <= p_ptr->csp)
5231                                         {
5232                                                 /* Use some mana */
5233                                                 p_ptr->csp -= 20;
5234                                         }
5235
5236                                         /* Over-exert the player */
5237                                         else
5238                                         {
5239                                                 int oops = 20 - p_ptr->csp;
5240
5241                                                 /* No mana left */
5242                                                 p_ptr->csp = 0;
5243                                                 p_ptr->csp_frac = 0;
5244
5245                                                 /* Message */
5246 #ifdef JP
5247                                                 msg_print("ÀФòÀ©¸æ¤Ç¤­¤Ê¤¤¡ª");
5248 #else
5249                                                 msg_print("You are too weak to control the stone!");
5250 #endif
5251
5252                                                 /* Hack -- Bypass free action */
5253                                                 (void)set_paralyzed(p_ptr->paralyzed +
5254                                                         randint1(5 * oops + 1));
5255
5256                                                 /* Confusing. */
5257                                                 (void)set_confused(p_ptr->confused +
5258                                                         randint1(5 * oops + 1));
5259                                         }
5260
5261                                         /* Redraw mana */
5262                                         p_ptr->redraw |= (PR_MANA);
5263                                 }
5264
5265 #ifdef JP
5266                                 take_hit(DAMAGE_LOSELIFE, damroll(1, 12), "´í¸±¤ÊÈëÌ©", -1);
5267 #else
5268                                 take_hit(DAMAGE_LOSELIFE, damroll(1, 12), "perilous secrets", -1);
5269 #endif
5270
5271                                 /* Confusing. */
5272                                 if (one_in_(5)) (void)set_confused(p_ptr->confused +
5273                                         randint1(10));
5274
5275                                 /* Exercise a little care... */
5276                                 if (one_in_(20))
5277 #ifdef JP
5278                                         take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "´í¸±¤ÊÈëÌ©", -1);
5279 #else
5280                                         take_hit(DAMAGE_LOSELIFE, damroll(4, 10), "perilous secrets", -1);
5281 #endif
5282                                 o_ptr->timeout = 0;
5283                                 break;
5284                         }
5285
5286                         case ART_BOROMIR:
5287                         {
5288                                 if (music_singing_any()) stop_singing();
5289 #ifdef JP
5290                                 msg_print("¤¢¤Ê¤¿¤ÏÎ϶¯¤¤ÆÍÉ÷¤ò¿á¤­ÌĤ餷¤¿¡£¼þ°Ï¤ÎŨ¤¬¿Ì¤¨¾å¤Ã¤Æ¤¤¤ë!");
5291 #else
5292                                 msg_print("You wind a mighty blast; your enemies tremble!");
5293 #endif
5294                                 (void)turn_monsters((3 * p_ptr->lev / 2) + 10);
5295                                 o_ptr->timeout = randint0(40) + 40;
5296                                 break;
5297                         }
5298                         case ART_FARAMIR:
5299                         {
5300 #ifdef JP
5301                                 msg_print("¤¢¤Ê¤¿¤Ï³²Ãî¤ò°ìÁݤ·¤¿¡£");
5302 #else
5303                                 msg_print("You exterminate small life.");
5304 #endif
5305                                 (void)dispel_monsters(4);
5306                                 o_ptr->timeout = randint0(55) + 55;
5307                                 break;
5308                         }
5309
5310                         case ART_HIMRING:
5311                         {
5312 #ifdef JP
5313                                 msg_print("Æߤ¤²»¤¬ÊÕ¤ê¤òÊñ¤ß¤³¤ó¤À¡£");
5314 #else
5315                                 msg_print("A shrill wailing sound surrounds you.");
5316 #endif
5317                                 (void)set_protevil(randint1(25) + p_ptr->lev, FALSE);
5318                                 o_ptr->timeout = randint0(200) + 200;
5319                                 break;
5320                         }
5321
5322                         case ART_ICANUS:
5323                         {
5324
5325 #ifdef JP
5326                                 msg_print("¥í¡¼¥Ö¤¬½ã¿è¤ÊËâÎϤǿ̤¨¤¿¡£");
5327 #else
5328                                 msg_print("The robe pulsates with raw mana...");
5329 #endif
5330                                 if (!get_aim_dir(&dir)) return;
5331                                 fire_bolt(GF_MANA, dir, 120);
5332                                 o_ptr->timeout = randint0(120) + 120;
5333                                 break;
5334                         }
5335                         case ART_HURIN:
5336                         {
5337                                 (void)set_fast(randint1(50) + 50, FALSE);
5338                                 hp_player(10);
5339                                 set_afraid(0);
5340                                 set_hero(randint1(50) + 50, FALSE);
5341                                 o_ptr->timeout = randint0(200) + 100;
5342                                 break;
5343                         }
5344                         case ART_GIL_GALAD:
5345                         {
5346 #ifdef JP
5347                                 msg_print("¥·¡¼¥ë¥É¤¬âÁ¤·¤¤¸÷¤Çµ±¤¤¤¿¡¥¡¥¡¥");
5348 #else
5349                                 msg_print("Your shield gleams with blinding light...");
5350 #endif
5351                                 fire_ball(GF_LITE, 0, 300, 6);
5352                                 confuse_monsters(3 * p_ptr->lev / 2);
5353                                 o_ptr->timeout = 250;
5354                                 break;
5355                         }
5356                         case ART_YENDOR:
5357                         {
5358 #ifdef JP
5359                                 msg_print("¥«¡¼¥É¤¬Çò¤¯µ±¤¤¤¿¡¥¡¥¡¥");
5360 #else
5361                                 msg_print("Your card gleams with blinding light...");
5362 #endif
5363                                 if (!recharge(1000)) return;
5364                                 o_ptr->timeout = 200;
5365                                 break;
5366                         }
5367                         case ART_MURAMASA:
5368                         {
5369 #ifdef JP
5370                                 if (get_check("ËÜÅö¤Ë»È¤¤¤Þ¤¹¤«¡©"))
5371 #else
5372                                 if (get_check("Are you sure?!"))
5373 #endif
5374                                 {
5375 #ifdef JP
5376                                         msg_print("¼Àµ¤¬¿Ì¤¨¤¿¡¥¡¥¡¥");
5377 #else
5378                                         msg_print("The Muramasa pulsates...");
5379 #endif
5380                                         do_inc_stat(A_STR);
5381                                         if (one_in_(2))
5382                                         {
5383 #ifdef JP
5384                                                 msg_print("¼Àµ¤Ï²õ¤ì¤¿¡ª");
5385 #else
5386                                                 msg_print("The Muramasa is destroyed!");
5387 #endif
5388                                                 curse_weapon(TRUE, item);
5389                                         }
5390                                 }
5391                                 break;
5392                         }
5393                         case ART_FLY_STONE:
5394                         {
5395 #ifdef JP
5396                                 msg_print("ÀФ¬ÀÄÇò¤¯¸÷¤Ã¤¿¡¥¡¥¡¥");
5397 #else
5398                                 msg_print("Your stone glows pale...");
5399 #endif
5400
5401                                 if (!get_aim_dir(&dir)) return;
5402                                 fire_ball(GF_MANA, dir, 400, 4);
5403                                 o_ptr->timeout = randint0(250) + 250;
5404                                 break;
5405                         }
5406                         case ART_TAIKOBO:
5407                         {
5408                                 int x, y;
5409
5410                                 if (!get_rep_dir2(&dir)) return;
5411                                 y = py+ddy[dir];
5412                                 x = px+ddx[dir];
5413                                 tsuri_dir = dir;
5414                                 if (!cave_have_flag_bold(y, x, FF_WATER))
5415                                 {
5416 #ifdef JP
5417                                         msg_print("¤½¤³¤Ï¿åÊդǤϤʤ¤¡£");
5418 #else
5419                                         msg_print("There is no fishing place.");
5420 #endif
5421                                         return;
5422                                 }
5423                                 else if (cave[y][x].m_idx)
5424                                 {
5425                                         char m_name[80];
5426                                         monster_desc(m_name, &m_list[cave[y][x].m_idx], 0);
5427 #ifdef JP
5428                                         msg_format("%s¤¬¼ÙËâ¤À¡ª", m_name);
5429 #else
5430                                         msg_format("%^s is stand in your way.", m_name);
5431 #endif
5432                                         energy_use = 0;
5433                                         return;
5434                                 }
5435                                 set_action(ACTION_FISH);
5436                                 p_ptr->redraw |= (PR_STATE);
5437                                 break;
5438                         }
5439                         case ART_JONES:
5440                         {
5441                                 if (!get_aim_dir(&dir)) return;
5442 #ifdef JP
5443                                 msg_print("¥à¥Á¤ò¿­¤Ð¤·¤¿¡£");
5444 #else
5445                                 msg_print("You stretched your whip.");
5446 #endif
5447
5448                                 fetch(dir, 500, TRUE);
5449                                 o_ptr->timeout = randint0(25) + 25;
5450                                 break;
5451                         }
5452                         case ART_ARRYU:
5453                         {
5454                                 u32b mode = PM_ALLOW_GROUP;
5455                                 bool pet = !one_in_(5);
5456                                 if (pet) mode |= PM_FORCE_PET;
5457                                 else mode |= PM_NO_PET;
5458
5459                                 if (summon_specific((pet ? -1 : 0), py, px, ((p_ptr->lev * 3) / 2), SUMMON_HOUND, mode))
5460                                 {
5461
5462                                         if (pet)
5463 #ifdef JP
5464                                                 msg_print("¥Ï¥¦¥ó¥É¤¬¤¢¤Ê¤¿¤Î²¼ËͤȤ·¤Æ½Ð¸½¤·¤¿¡£");
5465 #else
5466                                         msg_print("A group of hounds appear as your servant.");
5467 #endif
5468
5469                                         else
5470 #ifdef JP
5471                                                 msg_print("¥Ï¥¦¥ó¥É¤Ï¤¢¤Ê¤¿¤Ë²ç¤ò¸þ¤±¤Æ¤¤¤ë¡ª");
5472 #else
5473                                                 msg_print("A group of hounds appear as your enemy!");
5474 #endif
5475
5476                                 }
5477
5478                                 o_ptr->timeout = 300 + randint1(150);
5479                                 break;
5480                         }
5481
5482                         case ART_GAEBOLG:
5483                         {
5484 #ifdef JP
5485                                 msg_print("¥¹¥Ô¥¢¤ÏâÁ¤·¤¯µ±¤¤¤¿...");
5486 #else
5487                                 msg_print("Your spear grows brightly...");
5488 #endif
5489
5490                                 if (!get_aim_dir(&dir)) return;
5491                                 fire_ball(GF_LITE, dir, 200, 3);
5492                                 o_ptr->timeout = randint0(200) + 200;
5493                                 break;
5494                         }
5495
5496                         case ART_INROU:
5497                         {
5498                                 int count = 0, i;
5499                                 monster_type *m_ptr;
5500 #ifndef JP
5501                                 cptr kakusan = "";
5502 #endif
5503
5504                                 if (summon_named_creature(0, py, px, MON_SUKE, PM_FORCE_PET))
5505                                 {
5506 #ifdef JP
5507                                         msg_print("¡Ø½õ¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
5508 #else
5509                                         msg_print("Suke-san apperars.");
5510                                         kakusan = "Suke-san";
5511 #endif
5512                                         count++;
5513                                 }
5514                                 if (summon_named_creature(0, py, px, MON_KAKU, PM_FORCE_PET))
5515                                 {
5516 #ifdef JP
5517                                         msg_print("¡Ø³Ê¤µ¤ó¡Ù¤¬¸½¤ì¤¿¡£");
5518 #else
5519                                         msg_print("Kaku-san appears.");
5520                                         kakusan = "Kaku-san";
5521 #endif
5522                                         count++;
5523                                 }
5524                                 if (!count)
5525                                 {
5526                                         for (i = m_max - 1; i > 0; i--)
5527                                         {
5528                                                 m_ptr = &m_list[i];
5529                                                 if (!m_ptr->r_idx) continue;
5530                                                 if (!((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) continue;
5531                                                 if (!los(m_ptr->fy, m_ptr->fx, py, px)) continue;
5532                                                 if (!projectable(m_ptr->fy, m_ptr->fx, py, px)) continue;
5533                                                 count++;
5534                                                 break;
5535                                         }
5536                                 }
5537
5538                                 if (count)
5539                                 {
5540 #ifdef JP
5541                                         msg_print("¡Ö¼Ô¤É¤â¡¢¤Ò¤«¤¨¤ª¤í¤¦¡ª¡ª¡ª¤³¤Î¤ªÊý¤ò¤É¤Ê¤¿¤È¤³¤³¤í¤¨¤ë¡£¡×");
5542 #else
5543                                         msg_format("%^s says 'WHO do you think this person is! Bow your head, down your knees!'", kakusan);
5544 #endif
5545
5546                                         sukekaku = TRUE;
5547                                         stun_monsters(120);
5548                                         confuse_monsters(120);
5549                                         turn_monsters(120);
5550                                         stasis_monsters(120);
5551                                         sukekaku = FALSE;
5552                                 }
5553                                 else
5554                                 {
5555 #ifdef JP
5556                                         msg_print("¤·¤«¤·¡¢²¿¤âµ¯¤­¤Ê¤«¤Ã¤¿¡£");
5557 #else
5558                                         msg_print("Nothing happen.");
5559 #endif
5560                                 }
5561                                 o_ptr->timeout = randint0(150) + 150;
5562                                 break;
5563                         }
5564
5565                         case ART_HYOUSIGI:
5566                         {
5567 #ifdef JP
5568                                 msg_print("Çï»ÒÌÚ¤òÂǤä¿¡£");
5569 #else
5570                                 msg_print("You beat Your wooden clappers.");
5571 #endif
5572                                 aggravate_monsters(0);
5573                                 break;
5574                         }
5575
5576                         case ART_MATOI:
5577                         case ART_AEGISFANG:
5578                         {
5579                                 set_hero(randint1(25)+25, FALSE);
5580                                 hp_player(10);
5581                                 o_ptr->timeout = randint0(30) + 30;
5582                                 break;
5583                         }
5584
5585                         case ART_EARENDIL:
5586                         {
5587                                 (void)set_poisoned(0);
5588                                 (void)set_confused(0);
5589                                 (void)set_blind(0);
5590                                 (void)set_stun(0);
5591                                 (void)set_cut(0);
5592                                 (void)set_image(0);
5593
5594                                 o_ptr->timeout = 100;
5595                                 break;
5596                         }
5597
5598                         case ART_BOLISHOI:
5599                         {
5600                                 if (!get_aim_dir(&dir)) return;
5601                                 (void)charm_animal(dir, p_ptr->lev);
5602
5603                                 o_ptr->timeout = 200;
5604                                 break;
5605                         }
5606
5607                         case ART_ARUNRUTH:
5608                         {
5609 #ifdef JP
5610                                 msg_print("¥½¡¼¥É¤¬Ã¸¤¤¥Ö¥ë¡¼¤Ëµ±¤¤¤¿...");
5611 #else
5612                                 msg_print("Your sword glows a pale blue...");
5613 #endif
5614                                 if (!get_aim_dir(&dir)) return;
5615                                 fire_bolt(GF_COLD, dir, damroll(12, 8));
5616                                 o_ptr->timeout = 50;
5617                                 break;
5618                         }
5619                         case ART_BLOOD:
5620                         {
5621                                 int dummy, i;
5622 #ifdef JP
5623                                 msg_print("³ù¤¬ÌÀ¤ë¤¯µ±¤¤¤¿...");
5624 #else
5625                                 msg_print("Your scythe glows brightly!");
5626 #endif
5627                                 for (i = 0; i < TR_FLAG_SIZE; i++)
5628                                         o_ptr->art_flags[i] = a_info[ART_BLOOD].flags[i];
5629
5630                                 dummy = randint1(2)+randint1(2);
5631                                 for (i = 0; i < dummy; i++)
5632                                 {
5633                                         int flag = randint0(19);
5634                                         if (flag == 18) add_flag(o_ptr->art_flags, TR_SLAY_HUMAN);
5635                                         else add_flag(o_ptr->art_flags, TR_CHAOTIC + flag);
5636                                 }
5637                                 dummy = randint1(2);
5638                                 for (i = 0; i < dummy; i++)
5639                                         one_resistance(o_ptr);
5640                                 dummy = 2;
5641                                 for (i = 0; i < dummy; i++)
5642                                 {
5643                                         int tmp = randint0(11);
5644                                         if (tmp < 6) add_flag(o_ptr->art_flags, TR_STR + tmp);
5645                                         else add_flag(o_ptr->art_flags, TR_STEALTH + tmp - 6);
5646                                 }
5647                                 o_ptr->timeout = 3333;
5648                                 if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
5649                                 p_ptr->update |= (PU_BONUS | PU_HP);
5650                                 break;
5651                         }
5652                         case ART_KESHO:
5653                         {
5654 #ifdef JP
5655                                 msg_print("Î϶¯¤¯»Í¸Ô¤òƧ¤ó¤À¡£");
5656 #else
5657                                 msg_print("You stamp. (as if you are in a ring.)");
5658 #endif
5659                                 (void)set_hero(randint1(20) + 20, FALSE);
5660                                 dispel_evil(p_ptr->lev * 3);
5661                                 o_ptr->timeout = 100 + randint1(100);
5662                                 break;
5663                         }
5664                         case ART_MOOK:
5665                         {
5666 #ifdef JP
5667                                 msg_print("¥¯¥í¡¼¥¯¤¬Çò¤¯µ±¤¤¤¿...");
5668 #else
5669                                 msg_print("Your cloak grows white.");
5670 #endif
5671                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
5672                                 o_ptr->timeout = 40 + randint1(40);
5673                                 break;
5674                         }
5675                         case ART_HERMIT:
5676                         {
5677 #ifdef JP
5678                                 msg_print("¥à¥Á¤«¤é±Ô¤¤²»¤¬Î®¤ì½Ð¤¿...");
5679 #else
5680                                 msg_print("The whip lets out a shrill wail...");
5681 #endif
5682
5683                                 k = 3 * p_ptr->lev;
5684                                 (void)set_protevil(randint1(25) + k, FALSE);
5685                                 o_ptr->timeout = randint0(225) + 225;
5686                                 break;
5687                         }
5688                         case ART_JIZO:
5689                         {
5690                                 u32b mode = PM_ALLOW_GROUP;
5691                                 bool pet = !one_in_(5);
5692                                 if (pet) mode |= PM_FORCE_PET;
5693
5694                                 if (summon_named_creature(0, py, px, MON_JIZOTAKO, mode))
5695                                 {
5696                                         if (pet)
5697 #ifdef JP
5698                                                 msg_print("Âý¤¬¤¢¤Ê¤¿¤Î²¼ËͤȤ·¤Æ½Ð¸½¤·¤¿¡£");
5699 #else
5700                                         msg_print("A group of octopuses appear as your servant.");
5701 #endif
5702
5703                                         else
5704 #ifdef JP
5705                                                 msg_print("Âý¤Ï¤¢¤Ê¤¿¤òâˤó¤Ç¤¤¤ë¡ª");
5706 #else
5707                                                 msg_print("A group of octopuses appear as your enemy!");
5708 #endif
5709
5710                                 }
5711
5712                                 o_ptr->timeout = 300 + randint1(150);
5713                                 break;
5714                         }
5715
5716                         case ART_FUNDIN:
5717                         {
5718 #ifdef JP
5719                                 msg_print("Å´µå¤ÏÊÕ¤ê¤òÁ±¤Î¥ª¡¼¥é¤ÇËþ¤¿¤·¤¿...");
5720 #else
5721                                 msg_print("The iron ball floods the area with goodness...");
5722 #endif
5723
5724                                 dispel_evil(p_ptr->lev * 5);
5725                                 o_ptr->timeout = randint0(100) + 100;
5726                                 break;
5727                         }
5728
5729                         case ART_NIGHT:
5730                         {
5731 #ifdef JP
5732                                 msg_print("¥¢¥ß¥å¥ì¥Ã¥È¤¬¿¼¤¤°Ç¤Ëʤ¤ï¤ì¤¿...");
5733 #else
5734                                 msg_print("Your amulet is coverd in pitch-darkness...");
5735 #endif
5736                                 if (!get_aim_dir(&dir)) return;
5737                                 fire_ball(GF_DARK, dir, 250, 4);
5738                                 o_ptr->timeout = randint0(150) + 150;
5739                                 break;
5740                         }
5741                         case ART_HELL:
5742                         {
5743 #ifdef JP
5744                                 msg_print("¼óÎؤ¬¿¼¤¤°Ç¤Ëʤ¤ï¤ì¤¿...");
5745 #else
5746                                 msg_print("Your collar harness is coverd in pitch-darkness...");
5747 #endif
5748                                 if (!get_aim_dir(&dir)) return;
5749                                 fire_ball(GF_DARK, dir, 250, 4);
5750                                 o_ptr->timeout = randint0(150) + 150;
5751                                 break;
5752                         }
5753                         case ART_SACRED_KNIGHTS:
5754                         {
5755 #ifdef JP
5756                                 msg_print("¼ó¾þ¤ê¤¬¿¿¼Â¤ò¾È¤é¤·½Ð¤¹...");
5757 #else
5758                                 msg_print("Your amulet exhibits the truth...");
5759 #endif
5760                                 if (remove_all_curse())
5761                                 {
5762 #ifdef JP
5763                                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
5764 #else
5765                                         msg_print("You feel as if someone is watching over you.");
5766 #endif
5767                                 }
5768                                 (void)probing();
5769                                 break;
5770                         }
5771                         case ART_CHARMED:
5772                         {
5773 #ifdef JP
5774                                 msg_print("¥Ú¥ó¥À¥ó¥È¤¬ÀÄÇò¤¯¸÷¤Ã¤¿¡¥¡¥¡¥");
5775 #else
5776                                 msg_print("Your pendant glows pale...");
5777 #endif
5778                                 if (p_ptr->pclass == CLASS_MAGIC_EATER)
5779                                 {
5780                                         int i;
5781                                         for (i = 0; i < EATER_EXT*2; i++)
5782                                         {
5783                                                 p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i]*EATER_CHARGE/3;
5784                                                 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;
5785                                         }
5786                                         for (; i < EATER_EXT*3; i++)
5787                                         {
5788                                                 int k_idx = lookup_kind(TV_ROD, i-EATER_EXT*2);
5789                                                 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;
5790                                                 if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0;
5791                                         }
5792 #ifdef JP
5793                                         msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
5794 #else
5795                                         msg_print("You feel your head clear.");
5796 #endif
5797                                         p_ptr->window |= (PW_PLAYER);
5798                                 }
5799                                 else if (p_ptr->csp < p_ptr->msp)
5800                                 {
5801                                         p_ptr->csp = p_ptr->msp;
5802                                         p_ptr->csp_frac = 0;
5803 #ifdef JP
5804                                         msg_print("Ƭ¤¬¥Ï¥Ã¥­¥ê¤È¤·¤¿¡£");
5805 #else
5806                                         msg_print("You feel your head clear.");
5807 #endif
5808
5809                                         p_ptr->redraw |= (PR_MANA);
5810                                         p_ptr->window |= (PW_PLAYER);
5811                                         p_ptr->window |= (PW_SPELL);
5812                                 }
5813                                 o_ptr->timeout = 777;
5814                                 break;
5815                         }
5816                 }
5817
5818                 /* Window stuff */
5819                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5820
5821                 /* Done */
5822                 return;
5823         }
5824
5825         if (object_is_smith(o_ptr))
5826         {
5827                 switch (o_ptr->xtra3-1)
5828                 {
5829                 case ESSENCE_TMP_RES_ACID:
5830                         (void)set_oppose_acid(randint1(20) + 20, FALSE);
5831                         o_ptr->timeout = randint0(50) + 50;
5832                         return;
5833
5834                 case ESSENCE_TMP_RES_ELEC:
5835                         (void)set_oppose_elec(randint1(20) + 20, FALSE);
5836                         o_ptr->timeout = randint0(50) + 50;
5837                         return;
5838
5839                 case ESSENCE_TMP_RES_FIRE:
5840                         (void)set_oppose_fire(randint1(20) + 20, FALSE);
5841                         o_ptr->timeout = randint0(50) + 50;
5842                         return;
5843
5844                 case ESSENCE_TMP_RES_COLD:
5845                         (void)set_oppose_cold(randint1(20) + 20, FALSE);
5846                         o_ptr->timeout = randint0(50) + 50;
5847                         return;
5848
5849                 case TR_IMPACT:
5850                         earthquake(py, px, 5);
5851                         o_ptr->timeout = 100 + randint1(100);
5852                         
5853                         /* Window stuff */
5854                         p_ptr->window |= (PW_INVEN | PW_EQUIP);
5855
5856                         /* Done */
5857                         return;
5858                 }
5859         }
5860
5861
5862         if (o_ptr->name2 == EGO_TRUMP)
5863         {
5864                 teleport_player(100, 0L);
5865                 o_ptr->timeout = 50 + randint1(50);
5866
5867                 /* Window stuff */
5868                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5869
5870                 /* Done */
5871                 return;
5872         }
5873
5874
5875         if (o_ptr->name2 == EGO_LITE_ILLUMINATION)
5876         {
5877                 if (!o_ptr->xtra4 && ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN)))
5878                 {
5879 #ifdef JP
5880                         msg_print("dzÎÁ¤¬¤Ê¤¤¡£");
5881 #else
5882                         msg_print("It has no fuel.");
5883 #endif
5884                         energy_use = 0;
5885                         return;
5886                 }
5887                 lite_area(damroll(2, 15), 3);
5888                 o_ptr->timeout = randint0(10) + 10;
5889
5890                 /* Window stuff */
5891                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5892
5893                 return;
5894         }
5895
5896
5897         if (o_ptr->name2 == EGO_EARTHQUAKES)
5898         {
5899                 earthquake(py, px, 5);
5900                 o_ptr->timeout = 100 + randint1(100);
5901
5902                 /* Window stuff */
5903                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5904
5905                 /* Done */
5906                 return;
5907         }
5908
5909
5910         if (o_ptr->name2 == EGO_JUMP)
5911         {
5912                 teleport_player(10, 0L);
5913                 o_ptr->timeout = 10 + randint1(10);
5914
5915                 /* Window stuff */
5916                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
5917
5918                 /* Done */
5919                 return;
5920         }
5921
5922
5923         /* Hack -- Dragon Scale Mail can be activated as well */
5924         if (o_ptr->tval == TV_DRAG_ARMOR)
5925         {
5926                 /* Get a direction for breathing (or abort) */
5927                 if (!get_aim_dir(&dir)) return;
5928
5929                 if (music_singing_any()) stop_singing();
5930
5931                 /* Branch on the sub-type */
5932                 switch (o_ptr->sval)
5933                 {
5934                         case SV_DRAGON_BLUE:
5935                         {
5936 #ifdef JP
5937                                 msg_print("¤¢¤Ê¤¿¤Ï°ðºÊ¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5938 #else
5939                                 msg_print("You breathe lightning.");
5940 #endif
5941
5942                                 fire_ball(GF_ELEC, dir, 100, -2);
5943                                 o_ptr->timeout = randint0(150) + 150;
5944                                 break;
5945                         }
5946
5947                         case SV_DRAGON_WHITE:
5948                         {
5949 #ifdef JP
5950                                 msg_print("¤¢¤Ê¤¿¤ÏÎ䵤¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5951 #else
5952                                 msg_print("You breathe frost.");
5953 #endif
5954
5955                                 fire_ball(GF_COLD, dir, 110, -2);
5956                                 o_ptr->timeout = randint0(150) + 150;
5957                                 break;
5958                         }
5959
5960                         case SV_DRAGON_BLACK:
5961                         {
5962 #ifdef JP
5963                                 msg_print("¤¢¤Ê¤¿¤Ï»À¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5964 #else
5965                                 msg_print("You breathe acid.");
5966 #endif
5967
5968                                 fire_ball(GF_ACID, dir, 130, -2);
5969                                 o_ptr->timeout = randint0(150) + 150;
5970                                 break;
5971                         }
5972
5973                         case SV_DRAGON_GREEN:
5974                         {
5975 #ifdef JP
5976                                 msg_print("¤¢¤Ê¤¿¤ÏÆÇ¥¬¥¹¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5977 #else
5978                                 msg_print("You breathe poison gas.");
5979 #endif
5980
5981                                 fire_ball(GF_POIS, dir, 150, -2);
5982                                 o_ptr->timeout = randint0(180) + 180;
5983                                 break;
5984                         }
5985
5986                         case SV_DRAGON_RED:
5987                         {
5988 #ifdef JP
5989                                 msg_print("¤¢¤Ê¤¿¤Ï²Ð±ê¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
5990 #else
5991                                 msg_print("You breathe fire.");
5992 #endif
5993
5994                                 fire_ball(GF_FIRE, dir, 200, -2);
5995                                 o_ptr->timeout = randint0(200) + 200;
5996                                 break;
5997                         }
5998
5999                         case SV_DRAGON_MULTIHUED:
6000                         {
6001                                 chance = randint0(5);
6002 #ifdef JP
6003                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
6004                                            ((chance == 1) ? "°ðºÊ" :
6005                                             ((chance == 2) ? "Î䵤" :
6006                                              ((chance == 3) ? "»À" :
6007                                               ((chance == 4) ? "ÆÇ¥¬¥¹" : "²Ð±ê")))));
6008 #else
6009                                 msg_format("You breathe %s.",
6010                                            ((chance == 1) ? "lightning" :
6011                                             ((chance == 2) ? "frost" :
6012                                              ((chance == 3) ? "acid" :
6013                                               ((chance == 4) ? "poison gas" : "fire")))));
6014 #endif
6015
6016                                 fire_ball(((chance == 1) ? GF_ELEC :
6017                                            ((chance == 2) ? GF_COLD :
6018                                             ((chance == 3) ? GF_ACID :
6019                                              ((chance == 4) ? GF_POIS : GF_FIRE)))),
6020                                           dir, 250, -2);
6021                                 o_ptr->timeout = randint0(200) + 200;
6022                                 break;
6023                         }
6024
6025                         case SV_DRAGON_BRONZE:
6026                         {
6027 #ifdef JP
6028                                 msg_print("¤¢¤Ê¤¿¤Ïº®Íð¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
6029 #else
6030                                 msg_print("You breathe confusion.");
6031 #endif
6032
6033                                 fire_ball(GF_CONFUSION, dir, 120, -2);
6034                                 o_ptr->timeout = randint0(180) + 180;
6035                                 break;
6036                         }
6037
6038                         case SV_DRAGON_GOLD:
6039                         {
6040 #ifdef JP
6041                                 msg_print("¤¢¤Ê¤¿¤Ï¹ì²»¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
6042 #else
6043                                 msg_print("You breathe sound.");
6044 #endif
6045
6046                                 fire_ball(GF_SOUND, dir, 130, -2);
6047                                 o_ptr->timeout = randint0(180) + 180;
6048                                 break;
6049                         }
6050
6051                         case SV_DRAGON_CHAOS:
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 ? "chaos" : "disenchantment")));
6060 #endif
6061
6062                                 fire_ball((chance == 1 ? GF_CHAOS : GF_DISENCHANT),
6063                                           dir, 220, -2);
6064                                 o_ptr->timeout = randint0(200) + 200;
6065                                 break;
6066                         }
6067
6068                         case SV_DRAGON_LAW:
6069                         {
6070                                 chance = randint0(2);
6071 #ifdef JP
6072                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
6073                                            ((chance == 1 ? "¹ì²»" : "ÇËÊÒ")));
6074 #else
6075                                 msg_format("You breathe %s.",
6076                                            ((chance == 1 ? "sound" : "shards")));
6077 #endif
6078
6079                                 fire_ball((chance == 1 ? GF_SOUND : GF_SHARDS),
6080                                           dir, 230, -2);
6081                                 o_ptr->timeout = randint0(200) + 200;
6082                                 break;
6083                         }
6084
6085                         case SV_DRAGON_BALANCE:
6086                         {
6087                                 chance = randint0(4);
6088 #ifdef JP
6089                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿",
6090                                            ((chance == 1) ? "¥«¥ª¥¹" :
6091                                             ((chance == 2) ? "Îô²½" :
6092                                              ((chance == 3) ? "¹ì²»" : "ÇËÊÒ"))));
6093 #else
6094                                 msg_format("You breathe %s.",
6095                                            ((chance == 1) ? "chaos" :
6096                                             ((chance == 2) ? "disenchantment" :
6097                                              ((chance == 3) ? "sound" : "shards"))));
6098 #endif
6099
6100                                 fire_ball(((chance == 1) ? GF_CHAOS :
6101                                            ((chance == 2) ? GF_DISENCHANT :
6102                                             ((chance == 3) ? GF_SOUND : GF_SHARDS))),
6103                                           dir, 250, -2);
6104                                 o_ptr->timeout = randint0(200) + 200;
6105                                 break;
6106                         }
6107
6108                         case SV_DRAGON_SHINING:
6109                         {
6110                                 chance = randint0(2);
6111 #ifdef JP
6112                                 msg_format("¤¢¤Ê¤¿¤Ï%s¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£",
6113                                            ((chance == 0 ? "Á®¸÷" : "°Å¹õ")));
6114 #else
6115                                 msg_format("You breathe %s.",
6116                                            ((chance == 0 ? "light" : "darkness")));
6117 #endif
6118
6119                                 fire_ball((chance == 0 ? GF_LITE : GF_DARK), dir, 200, -2);
6120                                 o_ptr->timeout = randint0(200) + 200;
6121                                 break;
6122                         }
6123
6124                         case SV_DRAGON_POWER:
6125                         {
6126 #ifdef JP
6127 msg_print("¤¢¤Ê¤¿¤Ï¥¨¥ì¥á¥ó¥È¤Î¥Ö¥ì¥¹¤òÅǤ¤¤¿¡£");
6128 #else
6129                                 msg_print("You breathe the elements.");
6130 #endif
6131
6132                                 fire_ball(GF_MISSILE, dir, 300, -3);
6133                                 o_ptr->timeout = randint0(200) + 200;
6134                                 break;
6135                         }
6136                 }
6137
6138                 /* Window stuff */
6139                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
6140
6141                 /* Success */
6142                 return;
6143         }
6144
6145         else if (o_ptr->tval == TV_RING)
6146         {
6147                 if (object_is_ego(o_ptr))
6148                 {
6149                         bool success = TRUE;
6150
6151                         switch (o_ptr->name2)
6152                         {
6153                         case EGO_RING_HERO:
6154                                 (void)set_afraid(0);
6155                                 (void)set_hero(randint1(25) + 25, FALSE);
6156                                 (void)hp_player(10);
6157                                 o_ptr->timeout = randint1(100)+100;
6158                                 break;
6159                         case EGO_RING_MAGIC_MIS:
6160                                 if (!get_aim_dir(&dir)) return;
6161                                 fire_bolt(GF_MISSILE, dir, damroll(2, 6));
6162                                 o_ptr->timeout = 2;
6163                                 break;
6164                         case EGO_RING_FIRE_BOLT:
6165                                 if (!get_aim_dir(&dir)) return;
6166                                 fire_bolt(GF_FIRE, dir, damroll(9, 8));
6167                                 o_ptr->timeout = randint0(8) + 8;
6168                                 break;
6169                         case EGO_RING_COLD_BOLT:
6170                                 if (!get_aim_dir(&dir)) return;
6171                                 fire_bolt(GF_COLD, dir, damroll(6, 8));
6172                                 o_ptr->timeout = randint0(7) + 7;
6173                                 break;
6174                         case EGO_RING_ELEC_BOLT:
6175                                 if (!get_aim_dir(&dir)) return;
6176                                 fire_bolt(GF_ELEC, dir, damroll(4, 8));
6177                                 o_ptr->timeout = randint0(5) + 5;
6178                                 break;
6179                         case EGO_RING_ACID_BOLT:
6180                                 if (!get_aim_dir(&dir)) return;
6181                                 fire_bolt(GF_ACID, dir, damroll(5, 8));
6182                                 o_ptr->timeout = randint0(6) + 6;
6183                                 break;
6184                         case EGO_RING_MANA_BOLT:
6185                                 if (!get_aim_dir(&dir)) return;
6186                                 fire_bolt(GF_MANA, dir, 120);
6187                                 o_ptr->timeout = randint0(120)+120;
6188                                 break;
6189                         case EGO_RING_FIRE_BALL:
6190                                 if (!get_aim_dir(&dir)) return;
6191                                 fire_ball(GF_FIRE, dir, 100, 2);
6192                                 o_ptr->timeout = randint0(80) + 80;
6193                                 break;
6194                         case EGO_RING_COLD_BALL:
6195                                 if (!get_aim_dir(&dir)) return;
6196                                 fire_ball(GF_COLD, dir, 100, 2);
6197                                 o_ptr->timeout = randint0(80) + 80;
6198                                 break;
6199                         case EGO_RING_ELEC_BALL:
6200                                 if (!get_aim_dir(&dir)) return;
6201                                 fire_ball(GF_ELEC, dir, 100, 2);
6202                                 o_ptr->timeout = randint0(80) + 80;
6203                                 break;
6204                         case EGO_RING_ACID_BALL:
6205                                 if (!get_aim_dir(&dir)) return;
6206                                 fire_ball(GF_ACID, dir, 100, 2);
6207                                 o_ptr->timeout = randint0(80) + 80;
6208                                 break;
6209                         case EGO_RING_MANA_BALL:
6210                                 if (!get_aim_dir(&dir)) return;
6211                                 fire_ball(GF_MANA, dir, 250, 2);
6212                                 o_ptr->timeout = 300;
6213                                 break;
6214                         case EGO_RING_DRAGON_F:
6215                                 if (!get_aim_dir(&dir)) return;
6216                                 fire_ball(GF_FIRE, dir, 200, -2);
6217                                 if (o_ptr->sval == SV_RING_FLAMES)
6218                                 {
6219                                         (void)set_oppose_fire(randint1(20) + 20, FALSE);
6220                                         o_ptr->timeout = 200;
6221                                 }
6222                                 else o_ptr->timeout = 250;
6223                                 break;
6224                         case EGO_RING_DRAGON_C:
6225                                 if (!get_aim_dir(&dir)) return;
6226                                 fire_ball(GF_COLD, dir, 200, -2);
6227                                 if (o_ptr->sval == SV_RING_ICE)
6228                                 {
6229                                         (void)set_oppose_cold(randint1(20) + 20, FALSE);
6230                                         o_ptr->timeout = 200;
6231                                 }
6232                                 else o_ptr->timeout = 250;
6233                                 break;
6234                         case EGO_RING_M_DETECT:
6235                                 (void)detect_monsters_invis(255);
6236                                 (void)detect_monsters_normal(255);
6237                                 o_ptr->timeout = 150;
6238                                 break;
6239                         case EGO_RING_D_SPEED:
6240                                 (void)set_fast(randint1(30) + 15, FALSE);
6241                                 o_ptr->timeout = 100;
6242                                 break;
6243                         case EGO_RING_BERSERKER:
6244                                 (void)set_shero(randint1(25) + 25, FALSE);
6245                                 o_ptr->timeout = randint0(75)+75;
6246                                 break;
6247                         case EGO_RING_TELE_AWAY:
6248                                 if (!get_aim_dir(&dir)) return;
6249                                 teleport_monster(dir);
6250                                 o_ptr->timeout = 150;
6251                                 break;
6252                         case EGO_RING_TRUE:
6253                         {
6254                                 int v = randint1(25)+25;
6255                                 (void)set_afraid(0);
6256                                 (void)set_hero(v, FALSE);
6257                                 (void)hp_player(10);
6258                                 (void)set_blessed(v, FALSE);
6259                                 (void)set_oppose_acid(v, FALSE);
6260                                 (void)set_oppose_elec(v, FALSE);
6261                                 (void)set_oppose_fire(v, FALSE);
6262                                 (void)set_oppose_cold(v, FALSE);
6263                                 (void)set_oppose_pois(v, FALSE);
6264                                 (void)set_ultimate_res(v, FALSE);
6265                                 o_ptr->timeout = 777;
6266                                 break;
6267                         }
6268                         default:
6269                                 success = FALSE;
6270                                 break;
6271                         }
6272                         if (success) return;
6273                 }
6274
6275                 /* Get a direction for breathing (or abort) */
6276                 if (!get_aim_dir(&dir)) return;
6277
6278                 switch (o_ptr->sval)
6279                 {
6280                         case SV_RING_ACID:
6281                         {
6282                                 fire_ball(GF_ACID, dir, 100, 2);
6283                                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
6284                                 o_ptr->timeout = randint0(50) + 50;
6285                                 break;
6286                         }
6287
6288                         case SV_RING_ICE:
6289                         {
6290                                 fire_ball(GF_COLD, dir, 100, 2);
6291                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
6292                                 o_ptr->timeout = randint0(50) + 50;
6293                                 break;
6294                         }
6295
6296                         case SV_RING_FLAMES:
6297                         {
6298                                 fire_ball(GF_FIRE, dir, 100, 2);
6299                                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
6300                                 o_ptr->timeout = randint0(50) + 50;
6301                                 break;
6302                         }
6303
6304                         case SV_RING_ELEC:
6305                         {
6306                                 fire_ball(GF_ELEC, dir, 100, 2);
6307                                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
6308                                 o_ptr->timeout = randint0(50) + 50;
6309                                 break;
6310                         }
6311                 }
6312
6313                 /* Window stuff */
6314                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
6315
6316                 /* Success */
6317                 return;
6318         }
6319
6320         else if (o_ptr->tval == TV_AMULET)
6321         {
6322                 if (object_is_ego(o_ptr))
6323                 {
6324                         switch (o_ptr->name2)
6325                         {
6326                         case EGO_AMU_IDENT:
6327                                 if (!ident_spell(FALSE)) return;
6328                                 o_ptr->timeout = 10;
6329                                 break;
6330                         case EGO_AMU_CHARM:
6331                                 if (!get_aim_dir(&dir)) return;
6332                                 charm_monster(dir, MAX(20, p_ptr->lev));
6333                                 o_ptr->timeout = 200;
6334                                 break;
6335                         case EGO_AMU_JUMP:
6336                                 teleport_player(10, 0L);
6337                                 o_ptr->timeout = randint0(10) + 10;
6338                                 break;
6339                         case EGO_AMU_TELEPORT:
6340                                 teleport_player(100, 0L);
6341                                 o_ptr->timeout = randint0(50) + 50;
6342                                 break;
6343                         case EGO_AMU_D_DOOR:
6344                                 (void)dimension_door();
6345                                 o_ptr->timeout = 200;
6346                                 break;
6347                         case EGO_AMU_RES_FIRE_:
6348                                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
6349                                 o_ptr->timeout = randint0(50) + 50;
6350                                 break;
6351                         case EGO_AMU_RES_COLD_:
6352                                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
6353                                 o_ptr->timeout = randint0(50) + 50;
6354                                 break;
6355                         case EGO_AMU_RES_ELEC_:
6356                                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
6357                                 o_ptr->timeout = randint0(50) + 50;
6358                                 break;
6359                         case EGO_AMU_RES_ACID_:
6360                                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
6361                                 o_ptr->timeout = randint0(50) + 50;
6362                                 break;
6363                         case EGO_AMU_DETECTION:
6364                                 detect_all(DETECT_RAD_DEFAULT);
6365                                 o_ptr->timeout = randint0(55)+55;
6366                                 break;
6367                         }
6368                 }
6369                 return;
6370         }
6371
6372         else if (o_ptr->tval == TV_WHISTLE)
6373         {
6374                 if (music_singing_any()) stop_singing();
6375
6376 #if 0
6377                 if (object_is_cursed(o_ptr))
6378                 {
6379 #ifdef JP
6380                         msg_print("¥«¥ó¹â¤¤²»¤¬¶Á¤­ÅϤä¿¡£");
6381 #else
6382                         msg_print("You produce a shrill whistling sound.");
6383 #endif
6384                         aggravate_monsters(0);
6385                 }
6386                 else
6387 #endif
6388                 {
6389                         int pet_ctr, i;
6390                         u16b *who;
6391                         int max_pet = 0;
6392                         u16b dummy_why;
6393
6394                         /* Allocate the "who" array */
6395                         C_MAKE(who, max_m_idx, u16b);
6396
6397                         /* Process the monsters (backwards) */
6398                         for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
6399                         {
6400                                 if (is_pet(&m_list[pet_ctr]) && (p_ptr->riding != pet_ctr))
6401                                   who[max_pet++] = pet_ctr;
6402                         }
6403
6404                         /* Select the sort method */
6405                         ang_sort_comp = ang_sort_comp_pet;
6406                         ang_sort_swap = ang_sort_swap_hook;
6407
6408                         ang_sort(who, &dummy_why, max_pet);
6409
6410                         /* Process the monsters (backwards) */
6411                         for (i = 0; i < max_pet; i++)
6412                         {
6413                                 pet_ctr = who[i];
6414                                 teleport_monster_to(pet_ctr, py, px, 100, TELEPORT_PASSIVE);
6415                         }
6416
6417                         /* Free the "who" array */
6418                         C_KILL(who, max_m_idx, u16b);
6419                 }
6420                 o_ptr->timeout = 100+randint1(100);
6421                 return;
6422         }
6423         else if (o_ptr->tval == TV_CAPTURE)
6424         {
6425                 if(!o_ptr->pval)
6426                 {
6427                         bool old_target_pet = target_pet;
6428                         target_pet = TRUE;
6429                         if (!get_aim_dir(&dir))
6430                         {
6431                                 target_pet = old_target_pet;
6432                                 return;
6433                         }
6434                         target_pet = old_target_pet;
6435
6436                         if(fire_ball(GF_CAPTURE, dir, 0, 0))
6437                         {
6438                                 o_ptr->pval = cap_mon;
6439                                 o_ptr->xtra3 = cap_mspeed;
6440                                 o_ptr->xtra4 = cap_hp;
6441                                 o_ptr->xtra5 = cap_maxhp;
6442                                 if (cap_nickname)
6443                                 {
6444                                         cptr t;
6445                                         char *s;
6446                                         char buf[80] = "";
6447
6448                                         if (o_ptr->inscription)
6449                                                 strcpy(buf, quark_str(o_ptr->inscription));
6450                                         s = buf;
6451                                         for (s = buf;*s && (*s != '#'); s++)
6452                                         {
6453 #ifdef JP
6454                                                 if (iskanji(*s)) s++;
6455 #endif
6456                                         }
6457                                         *s = '#';
6458                                         s++;
6459 #ifdef JP
6460  /*nothing*/
6461 #else
6462                                         *s++ = '\'';
6463 #endif
6464                                         t = quark_str(cap_nickname);
6465                                         while (*t)
6466                                         {
6467                                                 *s = *t;
6468                                                 s++;
6469                                                 t++;
6470                                         }
6471 #ifdef JP
6472  /*nothing*/
6473 #else
6474                                         *s++ = '\'';
6475 #endif
6476                                         *s = '\0';
6477                                         o_ptr->inscription = quark_add(buf);
6478                                 }
6479                         }
6480                 }
6481                 else
6482                 {
6483                         bool success = FALSE;
6484                         if (!get_rep_dir2(&dir)) return;
6485                         if (monster_can_enter(py + ddy[dir], px + ddx[dir], &r_info[o_ptr->pval], 0))
6486                         {
6487                                 if (place_monster_aux(0, py + ddy[dir], px + ddx[dir], o_ptr->pval, (PM_FORCE_PET | PM_NO_KAGE)))
6488                                 {
6489                                         if (o_ptr->xtra3) m_list[hack_m_idx_ii].mspeed = o_ptr->xtra3;
6490                                         if (o_ptr->xtra5) m_list[hack_m_idx_ii].max_maxhp = o_ptr->xtra5;
6491                                         if (o_ptr->xtra4) m_list[hack_m_idx_ii].hp = o_ptr->xtra4;
6492                                         m_list[hack_m_idx_ii].maxhp = m_list[hack_m_idx_ii].max_maxhp;
6493                                         if (o_ptr->inscription)
6494                                         {
6495                                                 char buf[80];
6496                                                 cptr t;
6497 #ifndef JP
6498                                                 bool quote = FALSE;
6499 #endif
6500
6501                                                 t = quark_str(o_ptr->inscription);
6502                                                 for (t = quark_str(o_ptr->inscription);*t && (*t != '#'); t++)
6503                                                 {
6504 #ifdef JP
6505                                                         if (iskanji(*t)) t++;
6506 #endif
6507                                                 }
6508                                                 if (*t)
6509                                                 {
6510                                                         char *s = buf;
6511                                                         t++;
6512 #ifdef JP
6513                                                         /* nothing */
6514 #else
6515                                                         if (*t =='\'')
6516                                                         {
6517                                                                 t++;
6518                                                                 quote = TRUE;
6519                                                         }
6520 #endif
6521                                                         while(*t)
6522                                                         {
6523                                                                 *s = *t;
6524                                                                 t++;
6525                                                                 s++;
6526                                                         }
6527 #ifdef JP
6528                                                         /* nothing */
6529 #else
6530                                                         if (quote && *(s-1) =='\'')
6531                                                                 s--;
6532 #endif
6533                                                         *s = '\0';
6534                                                         m_list[hack_m_idx_ii].nickname = quark_add(buf);
6535                                                         t = quark_str(o_ptr->inscription);
6536                                                         s = buf;
6537                                                         while(*t && (*t != '#'))
6538                                                         {
6539                                                                 *s = *t;
6540                                                                 t++;
6541                                                                 s++;
6542                                                         }
6543                                                         *s = '\0';
6544                                                         o_ptr->inscription = quark_add(buf);
6545                                                 }
6546                                         }
6547                                         o_ptr->pval = 0;
6548                                         o_ptr->xtra3 = 0;
6549                                         o_ptr->xtra4 = 0;
6550                                         o_ptr->xtra5 = 0;
6551                                         success = TRUE;
6552                                 }
6553                         }
6554                         if (!success)
6555 #ifdef JP
6556                                 msg_print("¤ª¤Ã¤È¡¢²òÊü¤Ë¼ºÇÔ¤·¤¿¡£");
6557 #else
6558                                 msg_print("Oops.  You failed to release your pet.");
6559 #endif
6560                 }
6561                 return;
6562         }
6563
6564         /* Mistake */
6565 #ifdef JP
6566         msg_print("¤ª¤Ã¤È¡¢¤³¤Î¥¢¥¤¥Æ¥à¤Ï»ÏÆ°¤Ç¤­¤Ê¤¤¡£");
6567 #else
6568         msg_print("Oops.  That object cannot be activated.");
6569 #endif
6570
6571 }
6572
6573
6574 void do_cmd_activate(void)
6575 {
6576         int     item;
6577         cptr    q, s;
6578
6579
6580         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
6581         {
6582                 set_action(ACTION_NONE);
6583         }
6584
6585         item_tester_no_ryoute = TRUE;
6586         /* Prepare the hook */
6587         item_tester_hook = item_tester_hook_activate;
6588
6589         /* Get an item */
6590 #ifdef JP
6591         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò»ÏÆ°¤µ¤»¤Þ¤¹¤«? ";
6592         s = "»ÏÆ°¤Ç¤­¤ë¥¢¥¤¥Æ¥à¤òÁõÈ÷¤·¤Æ¤¤¤Ê¤¤¡£";
6593 #else
6594         q = "Activate which item? ";
6595         s = "You have nothing to activate.";
6596 #endif
6597
6598         if (!get_item(&item, q, s, (USE_EQUIP))) return;
6599
6600         /* Activate the item */
6601         do_cmd_activate_aux(item);
6602 }
6603
6604
6605 /*
6606  * Hook to determine if an object is useable
6607  */
6608 static bool item_tester_hook_use(object_type *o_ptr)
6609 {
6610         u32b flgs[TR_FLAG_SIZE];
6611
6612         /* Ammo */
6613         if (o_ptr->tval == p_ptr->tval_ammo)
6614                 return (TRUE);
6615
6616         /* Useable object */
6617         switch (o_ptr->tval)
6618         {
6619                 case TV_SPIKE:
6620                 case TV_STAFF:
6621                 case TV_WAND:
6622                 case TV_ROD:
6623                 case TV_SCROLL:
6624                 case TV_POTION:
6625                 case TV_FOOD:
6626                 {
6627                         return (TRUE);
6628                 }
6629
6630                 default:
6631                 {
6632                         int i;
6633
6634                         /* Not known */
6635                         if (!object_is_known(o_ptr)) return (FALSE);
6636
6637                         /* HACK - only items from the equipment can be activated */
6638                         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6639                         {
6640                                 if (&inventory[i] == o_ptr)
6641                                 {
6642                                         /* Extract the flags */
6643                                         object_flags(o_ptr, flgs);
6644
6645                                         /* Check activation flag */
6646                                         if (have_flag(flgs, TR_ACTIVATE)) return (TRUE);
6647                                 }
6648                         }
6649                 }
6650         }
6651
6652         /* Assume not */
6653         return (FALSE);
6654 }
6655
6656
6657 /*
6658  * Use an item
6659  * XXX - Add actions for other item types
6660  */
6661 void do_cmd_use(void)
6662 {
6663         int         item;
6664         object_type *o_ptr;
6665         cptr        q, s;
6666
6667         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
6668         {
6669                 set_action(ACTION_NONE);
6670         }
6671
6672         item_tester_no_ryoute = TRUE;
6673         /* Prepare the hook */
6674         item_tester_hook = item_tester_hook_use;
6675
6676         /* Get an item */
6677 #ifdef JP
6678 q = "¤É¤ì¤ò»È¤¤¤Þ¤¹¤«¡©";
6679 s = "»È¤¨¤ë¤â¤Î¤¬¤¢¤ê¤Þ¤»¤ó¡£";
6680 #else
6681         q = "Use which item? ";
6682         s = "You have nothing to use.";
6683 #endif
6684
6685         if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR))) return;
6686
6687         /* Get the item (in the pack) */
6688         if (item >= 0)
6689         {
6690                 o_ptr = &inventory[item];
6691         }
6692         /* Get the item (on the floor) */
6693         else
6694         {
6695                 o_ptr = &o_list[0 - item];
6696         }
6697
6698         switch (o_ptr->tval)
6699         {
6700                 /* Spike a door */
6701                 case TV_SPIKE:
6702                 {
6703                         do_cmd_spike();
6704                         break;
6705                 }
6706
6707                 /* Eat some food */
6708                 case TV_FOOD:
6709                 {
6710                         do_cmd_eat_food_aux(item);
6711                         break;
6712                 }
6713
6714                 /* Aim a wand */
6715                 case TV_WAND:
6716                 {
6717                         do_cmd_aim_wand_aux(item);
6718                         break;
6719                 }
6720
6721                 /* Use a staff */
6722                 case TV_STAFF:
6723                 {
6724                         do_cmd_use_staff_aux(item);
6725                         break;
6726                 }
6727
6728                 /* Zap a rod */
6729                 case TV_ROD:
6730                 {
6731                         do_cmd_zap_rod_aux(item);
6732                         break;
6733                 }
6734
6735                 /* Quaff a potion */
6736                 case TV_POTION:
6737                 {
6738                         do_cmd_quaff_potion_aux(item);
6739                         break;
6740                 }
6741
6742                 /* Read a scroll */
6743                 case TV_SCROLL:
6744                 {
6745                         /* Check some conditions */
6746                         if (p_ptr->blind)
6747                         {
6748 #ifdef JP
6749 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡£");
6750 #else
6751                                 msg_print("You can't see anything.");
6752 #endif
6753
6754                                 return;
6755                         }
6756                         if (no_lite())
6757                         {
6758 #ifdef JP
6759 msg_print("ÌÀ¤«¤ê¤¬¤Ê¤¤¤Î¤Ç¡¢°Å¤¯¤ÆÆɤá¤Ê¤¤¡£");
6760 #else
6761                                 msg_print("You have no light to read by.");
6762 #endif
6763
6764                                 return;
6765                         }
6766                         if (p_ptr->confused)
6767                         {
6768 #ifdef JP
6769 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡ª");
6770 #else
6771                                 msg_print("You are too confused!");
6772 #endif
6773
6774                                 return;
6775                         }
6776
6777                   do_cmd_read_scroll_aux(item, TRUE);
6778                   break;
6779                 }
6780
6781                 /* Fire ammo */
6782                 case TV_SHOT:
6783                 case TV_ARROW:
6784                 case TV_BOLT:
6785                 {
6786                         do_cmd_fire_aux(item, &inventory[INVEN_BOW]);
6787                         break;
6788                 }
6789
6790                 /* Activate an artifact */
6791                 default:
6792                 {
6793                         do_cmd_activate_aux(item);
6794                         break;
6795                 }
6796         }
6797 }
6798
6799 static int select_magic_eater(bool only_browse)
6800 {
6801         int ext=0;
6802         char choice;
6803         bool flag, request_list;
6804         int tval = 0;
6805         int             ask = TRUE, i = 0;
6806         char            out_val[160];
6807
6808         int menu_line = (use_menu ? 1 : 0);
6809
6810 #ifdef ALLOW_REPEAT
6811         int sn;
6812         if (repeat_pull(&sn))
6813         {
6814                 /* Verify the spell */
6815                 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))
6816                         return sn;
6817                 else if (sn < EATER_EXT*2 && !(p_ptr->magic_num1[sn] < EATER_CHARGE))
6818                         return sn;
6819         }
6820         
6821 #endif /* ALLOW_REPEAT */
6822
6823         for (i = 0; i < 108; i++)
6824         {
6825                 if (p_ptr->magic_num2[i]) break;
6826         }
6827         if (i == 108)
6828         {
6829 #ifdef JP
6830                 msg_print("ËâË¡¤ò³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
6831 #else
6832                 msg_print("You don't have any magic!");
6833 #endif
6834                 return -1;
6835         }
6836
6837         if (use_menu)
6838         {
6839                 screen_save();
6840
6841                 while(!tval)
6842                 {
6843 #ifdef JP
6844                         prt(format(" %s ¾ó", (menu_line == 1) ? "¡Õ" : "  "), 2, 14);
6845                         prt(format(" %s ËâË¡ËÀ", (menu_line == 2) ? "¡Õ" : "  "), 3, 14);
6846                         prt(format(" %s ¥í¥Ã¥É", (menu_line == 3) ? "¡Õ" : "  "), 4, 14);
6847                         prt("¤É¤Î¼ïÎà¤ÎËâË¡¤ò»È¤¤¤Þ¤¹¤«¡©", 0, 0);
6848 #else
6849                         prt(format(" %s staff", (menu_line == 1) ? "> " : "  "), 2, 14);
6850                         prt(format(" %s wand", (menu_line == 2) ? "> " : "  "), 3, 14);
6851                         prt(format(" %s rod", (menu_line == 3) ? "> " : "  "), 4, 14);
6852                         prt("Which type of magic do you use?", 0, 0);
6853 #endif
6854                         choice = inkey();
6855                         switch(choice)
6856                         {
6857                         case ESCAPE:
6858                         case 'z':
6859                         case 'Z':
6860                                 screen_load();
6861                                 return -1;
6862                         case '2':
6863                         case 'j':
6864                         case 'J':
6865                                 menu_line++;
6866                                 break;
6867                         case '8':
6868                         case 'k':
6869                         case 'K':
6870                                 menu_line+= 2;
6871                                 break;
6872                         case '\r':
6873                         case 'x':
6874                         case 'X':
6875                                 ext = (menu_line-1)*EATER_EXT;
6876                                 if (menu_line == 1) tval = TV_STAFF;
6877                                 else if (menu_line == 2) tval = TV_WAND;
6878                                 else tval = TV_ROD;
6879                                 break;
6880                         }
6881                         if (menu_line > 3) menu_line -= 3;
6882                 }
6883                 screen_load();
6884         }
6885         else
6886         {
6887         while (TRUE)
6888         {
6889 #ifdef JP
6890                 if (!get_com("[A] ¾ó, [B] ËâË¡ËÀ, [C] ¥í¥Ã¥É:", &choice, TRUE))
6891 #else
6892                 if (!get_com("[A] staff, [B] wand, [C] rod:", &choice, TRUE))
6893 #endif
6894                 {
6895                         return -1;
6896                 }
6897                 if (choice == 'A' || choice == 'a')
6898                 {
6899                         ext = 0;
6900                         tval = TV_STAFF;
6901                         break;
6902                 }
6903                 if (choice == 'B' || choice == 'b')
6904                 {
6905                         ext = EATER_EXT;
6906                         tval = TV_WAND;
6907                         break;
6908                 }
6909                 if (choice == 'C' || choice == 'c')
6910                 {
6911                         ext = EATER_EXT*2;
6912                         tval = TV_ROD;
6913                         break;
6914                 }
6915         }
6916         }
6917         for (i = ext; i < ext + EATER_EXT; i++)
6918         {
6919                 if (p_ptr->magic_num2[i])
6920                 {
6921                         if (use_menu) menu_line = i-ext+1;
6922                         break;
6923                 }
6924         }
6925         if (i == ext+EATER_EXT)
6926         {
6927 #ifdef JP
6928                 msg_print("¤½¤Î¼ïÎà¤ÎËâË¡¤Ï³Ð¤¨¤Æ¤¤¤Ê¤¤¡ª");
6929 #else
6930                 msg_print("You don't have that type of magic!");
6931 #endif
6932                 return -1;
6933         }
6934
6935         /* Nothing chosen yet */
6936         flag = FALSE;
6937
6938         /* Build a prompt */
6939 #ifdef JP
6940 (void) strnfmt(out_val, 78, "('*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤ÎËâÎϤò»È¤¤¤Þ¤¹¤«¡©");
6941 #else
6942         (void)strnfmt(out_val, 78, "(*=List, ESC=exit) Use which power? ");
6943 #endif
6944         
6945         /* Save the screen */
6946         screen_save();
6947
6948         request_list = always_show_list;
6949
6950         /* Get a spell from the user */
6951         while (!flag)
6952         {
6953                 /* Show the list */
6954                 if (request_list || use_menu)
6955                 {
6956                         byte y, x = 0;
6957                         int ctr, chance;
6958                         int k_idx;
6959                         char dummy[80];
6960                         int x1, y1, level;
6961                         byte col;
6962
6963                         strcpy(dummy, "");
6964
6965                         for (y = 1; y < 20; y++)
6966                                 prt("", y, x);
6967
6968                         y = 1;
6969
6970                         /* Print header(s) */
6971 #ifdef JP
6972                         prt(format("                           %s ¼ºÎ¨                           %s ¼ºÎ¨", (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô"), (tval == TV_ROD ? "  ¾õÂÖ  " : "»ÈÍѲó¿ô")), y++, x);
6973 #else
6974                         prt(format("                           %s Fail                           %s Fail", (tval == TV_ROD ? "  Stat  " : " Charges"), (tval == TV_ROD ? "  Stat  " : " Charges")), y++, x);
6975 #endif
6976
6977                         /* Print list */
6978                         for (ctr = 0; ctr < EATER_EXT; ctr++)
6979                         {
6980                                 if (!p_ptr->magic_num2[ctr+ext]) continue;
6981
6982                                 k_idx = lookup_kind(tval, ctr);
6983
6984                                 if (use_menu)
6985                                 {
6986                                         if (ctr == (menu_line-1))
6987 #ifdef JP
6988                                                 strcpy(dummy, "¡Õ");
6989 #else
6990                                         strcpy(dummy, "> ");
6991 #endif
6992                                         else strcpy(dummy, "  ");
6993                                                 
6994                                 }
6995                                 /* letter/number for power selection */
6996                                 else
6997                                 {
6998                                         char letter;
6999                                         if (ctr < 26)
7000                                                 letter = I2A(ctr);
7001                                         else
7002                                                 letter = '0' + ctr - 26;
7003                                         sprintf(dummy, "%c)",letter);
7004                                 }
7005                                 x1 = ((ctr < EATER_EXT/2) ? x : x + 40);
7006                                 y1 = ((ctr < EATER_EXT/2) ? y + ctr : y + ctr - EATER_EXT/2);
7007                                 level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
7008                                 chance = level * 4 / 5 + 20;
7009                                 chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
7010                                 level /= 2;
7011                                 if (p_ptr->lev > level)
7012                                 {
7013                                         chance -= 3 * (p_ptr->lev - level);
7014                                 }
7015                                 chance = mod_spell_chance_1(chance);
7016                                 chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
7017                                 /* Stunning makes spells harder */
7018                                 if (p_ptr->stun > 50) chance += 25;
7019                                 else if (p_ptr->stun) chance += 15;
7020
7021                                 if (chance > 95) chance = 95;
7022
7023                                 chance = mod_spell_chance_2(chance);
7024
7025                                 col = TERM_WHITE;
7026
7027                                 if (k_idx)
7028                                 {
7029                                         if (tval == TV_ROD)
7030                                         {
7031                                                 strcat(dummy, format(
7032 #ifdef JP
7033                                                                " %-22.22s ½¼Å¶:%2d/%2d%3d%%",
7034 #else
7035                                                                " %-22.22s   (%2d/%2d) %3d%%",
7036 #endif
7037                                                                k_name + k_info[k_idx].name, 
7038                                                                p_ptr->magic_num1[ctr+ext] ? 
7039                                                                (p_ptr->magic_num1[ctr+ext] - 1) / (EATER_ROD_CHARGE * k_info[k_idx].pval) +1 : 0, 
7040                                                                p_ptr->magic_num2[ctr+ext], chance));
7041                                                 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;
7042                                         }
7043                                         else
7044                                         {
7045                                                 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));
7046                                                 if (p_ptr->magic_num1[ctr+ext] < EATER_CHARGE) col = TERM_RED;
7047                                         }
7048                                 }
7049                                 else
7050                                         strcpy(dummy, "");
7051                                 c_prt(col, dummy, y1, x1);
7052                         }
7053                 }
7054
7055                 if (!get_com(out_val, &choice, FALSE)) break;
7056
7057                 if (use_menu && choice != ' ')
7058                 {
7059                         switch (choice)
7060                         {
7061                                 case '0':
7062                                 {
7063                                         screen_load();
7064                                         return 0;
7065                                 }
7066
7067                                 case '8':
7068                                 case 'k':
7069                                 case 'K':
7070                                 {
7071                                         do
7072                                         {
7073                                                 menu_line += EATER_EXT - 1;
7074                                                 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
7075                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
7076                                         break;
7077                                 }
7078
7079                                 case '2':
7080                                 case 'j':
7081                                 case 'J':
7082                                 {
7083                                         do
7084                                         {
7085                                                 menu_line++;
7086                                                 if (menu_line > EATER_EXT) menu_line -= EATER_EXT;
7087                                         } while(!p_ptr->magic_num2[menu_line+ext-1]);
7088                                         break;
7089                                 }
7090
7091                                 case '4':
7092                                 case 'h':
7093                                 case 'H':
7094                                 case '6':
7095                                 case 'l':
7096                                 case 'L':
7097                                 {
7098                                         bool reverse = FALSE;
7099                                         if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
7100                                         if (menu_line > EATER_EXT/2)
7101                                         {
7102                                                 menu_line -= EATER_EXT/2;
7103                                                 reverse = TRUE;
7104                                         }
7105                                         else menu_line+=EATER_EXT/2;
7106                                         while(!p_ptr->magic_num2[menu_line+ext-1])
7107                                         {
7108                                                 if (reverse)
7109                                                 {
7110                                                         menu_line--;
7111                                                         if (menu_line < 2) reverse = FALSE;
7112                                                 }
7113                                                 else
7114                                                 {
7115                                                         menu_line++;
7116                                                         if (menu_line > EATER_EXT-1) reverse = TRUE;
7117                                                 }
7118                                         }
7119                                         break;
7120                                 }
7121
7122                                 case 'x':
7123                                 case 'X':
7124                                 case '\r':
7125                                 {
7126                                         i = menu_line - 1;
7127                                         ask = FALSE;
7128                                         break;
7129                                 }
7130                         }
7131                 }
7132
7133                 /* Request redraw */
7134                 if (use_menu && ask) continue;
7135
7136                 /* Request redraw */
7137                 if (!use_menu && ((choice == ' ') || (choice == '*') || (choice == '?')))
7138                 {
7139                         /* Hide the list */
7140                         if (request_list)
7141                         {
7142                                 /* Hide list */
7143                                 request_list = FALSE;
7144                                 
7145                                 /* Restore the screen */
7146                                 screen_load();
7147                                 screen_save();
7148                         }
7149                         else
7150                                 request_list = TRUE;
7151
7152                         /* Redo asking */
7153                         continue;
7154                 }
7155
7156                 if (!use_menu)
7157                 {
7158                         if (isalpha(choice))
7159                         {
7160                                 /* Note verify */
7161                                 ask = (isupper(choice));
7162
7163                                 /* Lowercase */
7164                                 if (ask) choice = tolower(choice);
7165
7166                                 /* Extract request */
7167                                 i = (islower(choice) ? A2I(choice) : -1);
7168                         }
7169                         else
7170                         {
7171                                 ask = FALSE; /* Can't uppercase digits */
7172
7173                                 i = choice - '0' + 26;
7174                         }
7175                 }
7176
7177                 /* Totally Illegal */
7178                 if ((i < 0) || (i > EATER_EXT) || !p_ptr->magic_num2[i+ext])
7179                 {
7180                         bell();
7181                         continue;
7182                 }
7183
7184                 if (!only_browse)
7185                 {
7186                         /* Verify it */
7187                         if (ask)
7188                         {
7189                                 char tmp_val[160];
7190
7191                                 /* Prompt */
7192 #ifdef JP
7193                                 (void) strnfmt(tmp_val, 78, "%s¤ò»È¤¤¤Þ¤¹¤«¡© ", k_name + k_info[lookup_kind(tval ,i)].name);
7194 #else
7195                                 (void) strnfmt(tmp_val, 78, "Use %s?", k_name + k_info[lookup_kind(tval ,i)].name);
7196 #endif
7197
7198                                 /* Belay that order */
7199                                 if (!get_check(tmp_val)) continue;
7200                         }
7201                         if (tval == TV_ROD)
7202                         {
7203                                 if (p_ptr->magic_num1[ext+i]  > k_info[lookup_kind(tval, i)].pval * (p_ptr->magic_num2[ext+i] - 1) * EATER_ROD_CHARGE)
7204                                 {
7205 #ifdef JP
7206                                         msg_print("¤½¤ÎËâË¡¤Ï¤Þ¤À½¼Å¶¤·¤Æ¤¤¤ëºÇÃæ¤À¡£");
7207 #else
7208                                         msg_print("The magic are still charging.");
7209 #endif
7210                                         msg_print(NULL);
7211                                         if (use_menu) ask = TRUE;
7212                                         continue;
7213                                 }
7214                         }
7215                         else
7216                         {
7217                                 if (p_ptr->magic_num1[ext+i] < EATER_CHARGE)
7218                                 {
7219 #ifdef JP
7220                                         msg_print("¤½¤ÎËâË¡¤Ï»ÈÍѲó¿ô¤¬ÀÚ¤ì¤Æ¤¤¤ë¡£");
7221 #else
7222                                         msg_print("The magic has no charges left.");
7223 #endif
7224                                         msg_print(NULL);
7225                                         if (use_menu) ask = TRUE;
7226                                         continue;
7227                                 }
7228                         }
7229                 }
7230
7231                 /* Browse */
7232                 else
7233                 {
7234                         int line, j;
7235                         char temp[70 * 20];
7236
7237                         /* Clear lines, position cursor  (really should use strlen here) */
7238                         Term_erase(7, 23, 255);
7239                         Term_erase(7, 22, 255);
7240                         Term_erase(7, 21, 255);
7241                         Term_erase(7, 20, 255);
7242
7243                         roff_to_buf(k_text + k_info[lookup_kind(tval, i)].text, 62, temp, sizeof(temp));
7244                         for (j = 0, line = 21; temp[j]; j += 1 + strlen(&temp[j]))
7245                         {
7246                                 prt(&temp[j], line, 10);
7247                                 line++;
7248                         }
7249         
7250 #ifdef JP
7251                         prt("²¿¤«¥­¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£",0,0);
7252 #else
7253                         prt("Hit any key.",0,0);
7254 #endif
7255                         (void)inkey();
7256                         continue;
7257                 }
7258
7259                 /* Stop the loop */
7260                 flag = TRUE;
7261         }
7262
7263         /* Restore the screen */
7264         screen_load();
7265
7266         if (!flag) return -1;
7267
7268 #ifdef ALLOW_REPEAT
7269         repeat_push(ext+i);
7270 #endif /* ALLOW_REPEAT */
7271         return ext+i;
7272 }
7273
7274
7275 /*
7276  *  Use eaten rod, wand or staff
7277  */
7278 void do_cmd_magic_eater(bool only_browse)
7279 {
7280         int item, chance, level, k_idx, tval, sval;
7281         bool use_charge = TRUE;
7282
7283         /* Not when confused */
7284         if (!only_browse && p_ptr->confused)
7285         {
7286 #ifdef JP
7287 msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
7288 #else
7289                 msg_print("You are too confused!");
7290 #endif
7291
7292                 return;
7293         }
7294
7295         item = select_magic_eater(only_browse);
7296         if (item == -1)
7297         {
7298                 energy_use = 0;
7299                 return;
7300         }
7301         if (item >= EATER_EXT*2) {tval = TV_ROD;sval = item - EATER_EXT*2;}
7302         else if (item >= EATER_EXT) {tval = TV_WAND;sval = item - EATER_EXT;}
7303         else {tval = TV_STAFF;sval = item;}
7304         k_idx = lookup_kind(tval, sval);
7305
7306         level = (tval == TV_ROD ? k_info[k_idx].level * 5 / 6 - 5 : k_info[k_idx].level);
7307         chance = level * 4 / 5 + 20;
7308         chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
7309         level /= 2;
7310         if (p_ptr->lev > level)
7311         {
7312                 chance -= 3 * (p_ptr->lev - level);
7313         }
7314         chance = mod_spell_chance_1(chance);
7315         chance = MAX(chance, adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]]);
7316         /* Stunning makes spells harder */
7317         if (p_ptr->stun > 50) chance += 25;
7318         else if (p_ptr->stun) chance += 15;
7319
7320         if (chance > 95) chance = 95;
7321
7322         chance = mod_spell_chance_2(chance);
7323
7324         if (randint0(100) < chance)
7325         {
7326                 if (flush_failure) flush();
7327
7328 #ifdef JP
7329 msg_print("¼öʸ¤ò¤¦¤Þ¤¯¾§¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡ª");
7330 #else
7331                 msg_format("You failed to get the magic off!");
7332 #endif
7333
7334                 sound(SOUND_FAIL);
7335                 if (randint1(100) >= chance)
7336                         chg_virtue(V_CHANCE,-1);
7337                 energy_use = 100;
7338
7339                 return;
7340         }
7341         else
7342         {
7343                 int dir = 0;
7344
7345                 if (tval == TV_ROD)
7346                 {
7347                         if ((sval >= SV_ROD_MIN_DIRECTION) && (sval != SV_ROD_HAVOC) && (sval != SV_ROD_AGGRAVATE) && (sval != SV_ROD_PESTICIDE))
7348                                 if (!get_aim_dir(&dir)) return;
7349                         rod_effect(sval, dir, &use_charge, TRUE);
7350                         if (!use_charge) return;
7351                 }
7352                 else if (tval == TV_WAND)
7353                 {
7354                         if (!get_aim_dir(&dir)) return;
7355                         wand_effect(sval, dir, TRUE);
7356                 }
7357                 else
7358                 {
7359                         staff_effect(sval, &use_charge, TRUE, TRUE);
7360                         if (!use_charge) return;
7361                 }
7362                 if (randint1(100) < chance)
7363                         chg_virtue(V_CHANCE,1);
7364         }
7365         energy_use = 100;
7366         if (tval == TV_ROD) p_ptr->magic_num1[item] += k_info[k_idx].pval * EATER_ROD_CHARGE;
7367         else p_ptr->magic_num1[item] -= EATER_CHARGE;
7368 }