OSDN Git Service

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