OSDN Git Service

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